Opentelemetry Jaeger Exporter

The OpenTelemetry Jaeger Exporter allows to export OpenTelemetry traces to Jaeger. This exporter always send traces to the configured agent using Thrift compact protocol over UDP. An optional collector can be configured, in this case Thrift binary protocol over HTTP is used. gRPC is still not supported by this implementation.

Usage

from opentelemetry import trace
from opentelemetry.ext import jaeger
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 JaegerSpanExporter
jaeger_exporter = jaeger.JaegerSpanExporter(
    service_name='my-helloworld-service',
    # configure agent
    agent_host_name='localhost',
    agent_port=6831,
    # optional: configure also collector
    # collector_host_name='localhost',
    # collector_port=14268,
    # collector_endpoint='/api/traces?format=jaeger.thrift',
    # username=xxxx, # optional
    # password=xxxx, # optional
)

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

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

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

API

class opentelemetry.ext.jaeger.JaegerSpanExporter(service_name, agent_host_name='localhost', agent_port=6831, collector_host_name=None, collector_port=None, collector_endpoint='/api/traces?format=jaeger.thrift', username=None, password=None)[source]

Bases: opentelemetry.sdk.trace.export.SpanExporter

Jaeger span exporter for OpenTelemetry.

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

  • agent_host_name – The host name of the Jaeger-Agent.

  • agent_port – The port of the Jaeger-Agent.

  • collector_host_name – The host name of the Jaeger-Collector HTTP Thrift.

  • collector_port – The port of the Jaeger-Collector HTTP Thrift.

  • collector_endpoint – The endpoint of the Jaeger-Collector HTTP Thrift.

  • username – The user name of the Basic Auth if authentication is required.

  • password – The password of the Basic Auth if authentication is required.

property agent_client
property collector
export(spans)[source]

Exports a batch of telemetry data.

Parameters

spans – The list of opentelemetry.trace.Span objects to be exported

Returns

The result of the export

shutdown()[source]

Shuts down the exporter.

Called when the SDK is shut down.

class opentelemetry.ext.jaeger.AgentClientUDP(host_name, port, max_packet_size=65000, client=<class 'opentelemetry.ext.jaeger.gen.agent.Agent.Client'>)[source]

Bases: object

Implement a UDP client to agent.

Parameters
  • host_name – The host name of the Jaeger server.

  • port – The port of the Jaeger server.

  • max_packet_size – Maximum size of UDP packet.

  • client – Class for creating new client objects for agencies.

emit(batch)[source]
Parameters

batch (Batch) – Object to emit Jaeger spans.

class opentelemetry.ext.jaeger.Collector(thrift_url='', auth=None)[source]

Bases: object

Submits collected spans to Thrift HTTP server.

Parameters
  • thrift_url – URL of the Jaeger HTTP Thrift.

  • auth – Auth tuple that contains username and password for Basic Auth.

submit(batch)[source]

Submits batches to Thrift HTTP Server through Binary Protocol.

Parameters

batch (Batch) – Object to emit Jaeger spans.

Submodules

class opentelemetry.ext.jaeger.gen.jaeger.ttypes.TagType[source]

Bases: object

STRING = 0
DOUBLE = 1
BOOL = 2
LONG = 3
BINARY = 4
class opentelemetry.ext.jaeger.gen.jaeger.ttypes.SpanRefType[source]

Bases: object

CHILD_OF = 0
FOLLOWS_FROM = 1
class opentelemetry.ext.jaeger.gen.jaeger.ttypes.Tag(key=None, vType=None, vStr=None, vDouble=None, vBool=None, vLong=None, vBinary=None)[source]

Bases: object

- key
- vType
- vStr
- vDouble
- vBool
- vLong
- vBinary
thrift_spec = (None, (1, 11, 'key', 'UTF8', None), (2, 8, 'vType', None, None), (3, 11, 'vStr', 'UTF8', None), (4, 4, 'vDouble', None, None), (5, 2, 'vBool', None, None), (6, 10, 'vLong', None, None), (7, 11, 'vBinary', 'BINARY', None))
read(iprot)[source]
write(oprot)[source]
validate()[source]
class opentelemetry.ext.jaeger.gen.jaeger.ttypes.Log(timestamp=None, fields=None)[source]

Bases: object

- timestamp
- fields
thrift_spec = (None, (1, 10, 'timestamp', None, None), (2, 15, 'fields', (12, (<class 'opentelemetry.ext.jaeger.gen.jaeger.ttypes.Tag'>, (None, (1, 11, 'key', 'UTF8', None), (2, 8, 'vType', None, None), (3, 11, 'vStr', 'UTF8', None), (4, 4, 'vDouble', None, None), (5, 2, 'vBool', None, None), (6, 10, 'vLong', None, None), (7, 11, 'vBinary', 'BINARY', None))), False), None))
read(iprot)[source]
write(oprot)[source]
validate()[source]
class opentelemetry.ext.jaeger.gen.jaeger.ttypes.SpanRef(refType=None, traceIdLow=None, traceIdHigh=None, spanId=None)[source]

Bases: object

- refType
- traceIdLow
- traceIdHigh
- spanId
thrift_spec = (None, (1, 8, 'refType', None, None), (2, 10, 'traceIdLow', None, None), (3, 10, 'traceIdHigh', None, None), (4, 10, 'spanId', None, None))
read(iprot)[source]
write(oprot)[source]
validate()[source]
class opentelemetry.ext.jaeger.gen.jaeger.ttypes.Span(traceIdLow=None, traceIdHigh=None, spanId=None, parentSpanId=None, operationName=None, references=None, flags=None, startTime=None, duration=None, tags=None, logs=None)[source]

Bases: object

- traceIdLow
- traceIdHigh
- spanId
- parentSpanId
- operationName
- references
- flags
- startTime
- duration
- tags
- logs
thrift_spec = (None, (1, 10, 'traceIdLow', None, None), (2, 10, 'traceIdHigh', None, None), (3, 10, 'spanId', None, None), (4, 10, 'parentSpanId', None, None), (5, 11, 'operationName', 'UTF8', None), (6, 15, 'references', (12, (<class 'opentelemetry.ext.jaeger.gen.jaeger.ttypes.SpanRef'>, (None, (1, 8, 'refType', None, None), (2, 10, 'traceIdLow', None, None), (3, 10, 'traceIdHigh', None, None), (4, 10, 'spanId', None, None))), False), None), (7, 8, 'flags', None, None), (8, 10, 'startTime', None, None), (9, 10, 'duration', None, None), (10, 15, 'tags', (12, (<class 'opentelemetry.ext.jaeger.gen.jaeger.ttypes.Tag'>, (None, (1, 11, 'key', 'UTF8', None), (2, 8, 'vType', None, None), (3, 11, 'vStr', 'UTF8', None), (4, 4, 'vDouble', None, None), (5, 2, 'vBool', None, None), (6, 10, 'vLong', None, None), (7, 11, 'vBinary', 'BINARY', None))), False), None), (11, 15, 'logs', (12, (<class 'opentelemetry.ext.jaeger.gen.jaeger.ttypes.Log'>, (None, (1, 10, 'timestamp', None, None), (2, 15, 'fields', (12, (<class 'opentelemetry.ext.jaeger.gen.jaeger.ttypes.Tag'>, (None, (1, 11, 'key', 'UTF8', None), (2, 8, 'vType', None, None), (3, 11, 'vStr', 'UTF8', None), (4, 4, 'vDouble', None, None), (5, 2, 'vBool', None, None), (6, 10, 'vLong', None, None), (7, 11, 'vBinary', 'BINARY', None))), False), None))), False), None))
read(iprot)[source]
write(oprot)[source]
validate()[source]
class opentelemetry.ext.jaeger.gen.jaeger.ttypes.Process(serviceName=None, tags=None)[source]

Bases: object

- serviceName
- tags
thrift_spec = (None, (1, 11, 'serviceName', 'UTF8', None), (2, 15, 'tags', (12, (<class 'opentelemetry.ext.jaeger.gen.jaeger.ttypes.Tag'>, (None, (1, 11, 'key', 'UTF8', None), (2, 8, 'vType', None, None), (3, 11, 'vStr', 'UTF8', None), (4, 4, 'vDouble', None, None), (5, 2, 'vBool', None, None), (6, 10, 'vLong', None, None), (7, 11, 'vBinary', 'BINARY', None))), False), None))
read(iprot)[source]
write(oprot)[source]
validate()[source]
class opentelemetry.ext.jaeger.gen.jaeger.ttypes.Batch(process=None, spans=None)[source]

Bases: object

- process
- spans
thrift_spec = (None, (1, 12, 'process', (<class 'opentelemetry.ext.jaeger.gen.jaeger.ttypes.Process'>, (None, (1, 11, 'serviceName', 'UTF8', None), (2, 15, 'tags', (12, (<class 'opentelemetry.ext.jaeger.gen.jaeger.ttypes.Tag'>, (None, (1, 11, 'key', 'UTF8', None), (2, 8, 'vType', None, None), (3, 11, 'vStr', 'UTF8', None), (4, 4, 'vDouble', None, None), (5, 2, 'vBool', None, None), (6, 10, 'vLong', None, None), (7, 11, 'vBinary', 'BINARY', None))), False), None))), None), (2, 15, 'spans', (12, (<class 'opentelemetry.ext.jaeger.gen.jaeger.ttypes.Span'>, (None, (1, 10, 'traceIdLow', None, None), (2, 10, 'traceIdHigh', None, None), (3, 10, 'spanId', None, None), (4, 10, 'parentSpanId', None, None), (5, 11, 'operationName', 'UTF8', None), (6, 15, 'references', (12, (<class 'opentelemetry.ext.jaeger.gen.jaeger.ttypes.SpanRef'>, (None, (1, 8, 'refType', None, None), (2, 10, 'traceIdLow', None, None), (3, 10, 'traceIdHigh', None, None), (4, 10, 'spanId', None, None))), False), None), (7, 8, 'flags', None, None), (8, 10, 'startTime', None, None), (9, 10, 'duration', None, None), (10, 15, 'tags', (12, (<class 'opentelemetry.ext.jaeger.gen.jaeger.ttypes.Tag'>, (None, (1, 11, 'key', 'UTF8', None), (2, 8, 'vType', None, None), (3, 11, 'vStr', 'UTF8', None), (4, 4, 'vDouble', None, None), (5, 2, 'vBool', None, None), (6, 10, 'vLong', None, None), (7, 11, 'vBinary', 'BINARY', None))), False), None), (11, 15, 'logs', (12, (<class 'opentelemetry.ext.jaeger.gen.jaeger.ttypes.Log'>, (None, (1, 10, 'timestamp', None, None), (2, 15, 'fields', (12, (<class 'opentelemetry.ext.jaeger.gen.jaeger.ttypes.Tag'>, (None, (1, 11, 'key', 'UTF8', None), (2, 8, 'vType', None, None), (3, 11, 'vStr', 'UTF8', None), (4, 4, 'vDouble', None, None), (5, 2, 'vBool', None, None), (6, 10, 'vLong', None, None), (7, 11, 'vBinary', 'BINARY', None))), False), None))), False), None))), False), None))
read(iprot)[source]
write(oprot)[source]
validate()[source]
class opentelemetry.ext.jaeger.gen.jaeger.ttypes.BatchSubmitResponse(ok=None)[source]

Bases: object

- ok
thrift_spec = (None, (1, 2, 'ok', None, None))
read(iprot)[source]
write(oprot)[source]
validate()[source]