OpenTelemetry hook sampler
Project description
opentelemetry-hook-sampler
Custom function based sampler for opentelemetry-python
.
How to install
$ pip install opentelemetry-hook-sampler
How to use
import opentelemetry.trace
from opentelemetry.sdk.resources import SERVICE_NAME
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry_hook_sampler import HookSampler
def sampler_hook():
"""
Sample every 10 traces.
The example is static, but you can get info from any context available
in your application. E.g. http request, celery task, etc.
"""
return 10
resource = Resource(attributes={SERVICE_NAME: "foo"})
sampler = HookSampler(sampler_hook)
provider = TracerProvider(resource=resource, sampler=sampler)
opentelemetry.trace.set_tracer_provider(provider)
Honeycomb specific
Honeycomb expects a
SampleRate
attribute to normalize data. It is not OpenTelemetry spec, but
it is supported through opentelemetry_hook_sampler.HoneycombHookSampler
.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for opentelemetry-hook-sampler-0.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63ec0c21498e07cc76cf8c21fcb2510b42d972893107584ace77ec3b0093f85a |
|
MD5 | 6f81b8ede55adde255f0d9d09683247c |
|
BLAKE2b-256 | da2eac605f58afd07f7706fdcdb6bfbe2b4272cc870846601058157a55b88a76 |
Close
Hashes for opentelemetry_hook_sampler-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d0f870ebd69bda28e66c30fe3b517aae8d05e6a99427bc5e89c7e5e9f1ddbe75 |
|
MD5 | de64298e2b59ae61ed4b9c874297c5cd |
|
BLAKE2b-256 | ea9202ad7e2f1c5356d0378f76df663685451e5d6f78a5a5d60f33b58d87f38a |