Opentelemetry Zipkin Exporter

This library allows to export tracing data to Zipkin.

Usage

The OpenTelemetry Zipkin Exporter allows to export OpenTelemetry traces to Zipkin. This exporter always send traces to the configured Zipkin collector using HTTP.

from opentelemetry import trace
from opentelemetry.exporter import zipkin
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchExportSpanProcessor

trace.set_tracer_provider(TracerProvider())
tracer = trace.get_tracer(__name__)

# create a ZipkinSpanExporter
zipkin_exporter = zipkin.ZipkinSpanExporter(
    service_name="my-helloworld-service",
    # optional:
    # url="http://localhost:9411/api/v2/spans",
    # ipv4="",
    # ipv6="",
    # retry=False,
)

# Create a BatchExportSpanProcessor and add the exporter to it
span_processor = BatchExportSpanProcessor(zipkin_exporter)

# add to the tracer
trace.get_tracer_provider().add_span_processor(span_processor)

with tracer.start_as_current_span("foo"):
    print("Hello world!")

The exporter supports endpoint configuration via the OTEL_EXPORTER_ZIPKIN_ENDPOINT environment variables as defined in the Specification

API

class opentelemetry.exporter.zipkin.ZipkinSpanExporter(service_name, url=None, ipv4=None, ipv6=None, retry=False, max_tag_value_length=128)[source]

Bases: opentelemetry.sdk.trace.export.SpanExporter

Zipkin span exporter for OpenTelemetry.

Parameters
  • service_name (str) – Service that logged an annotation in a trace.Classifier when query for spans.

  • url (Optional[str]) – The Zipkin endpoint URL

  • ipv4 (Optional[str]) – Primary IPv4 address associated with this connection.

  • ipv6 (Optional[str]) – Primary IPv6 address associated with this connection.

  • retry (Optional[str]) – Set to True to configure the exporter to retry on failure.

export(spans)[source]

Exports a batch of telemetry data.

Parameters

spans (Sequence[Span]) – The list of opentelemetry.trace.Span objects to be exported

Return type

SpanExportResult

Returns

The result of the export

shutdown()[source]

Shuts down the exporter.

Called when the SDK is shut down.

Return type

None