Skip to main content

Honeycomb Samplers for OpenTelemetry

Project description

opentelemetry-samplers-python

NOTE: This is experimental and is subject to change a lot or go away entirely. Use with caution.

Honeycomb Samplers for use with the OpenTelemetry Python SDK

Samplers

Deterministic Sampler

This is a port of the deterministic sampler included in our Python Beeline. To use it, just instantiate it with a sample rate:

from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import (
    ConsoleSpanExporter,
    SimpleExportSpanProcessor,
)
from opentelemetry.ext.honeycomb.sampling import DeterministicSampler

sampler = DeterministicSampler(5) # every trace has a 20% chance of being sampled
trace.set_tracer_provider(TracerProvider(sampler=sampler))

trace.get_tracer_provider().add_span_processor(
    SimpleExportSpanProcessor(ConsoleSpanExporter())
)

tracer = trace.get_tracer(__name__)

with tracer.start_as_current_span("Test span"):
    with tracer.start_as_current_span("bar"):
        with tracer.start_as_current_span("baz"):
            print("Hello world from OpenTelemetry Python!")

Project details


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

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page