OpenTelemetry Jaeger Exporters¶
OpenTelemetry Jaeger Thrift Exporter¶
The OpenTelemetry Jaeger Thrift Exporter allows to export OpenTelemetry traces to Jaeger. This exporter always sends traces to the configured agent using the Thrift compact protocol over UDP. When it is not feasible to deploy Jaeger Agent next to the application, for example, when the application code is running as Lambda function, a collector can be configured to send spans using Thrift over HTTP. If both agent and collector are configured, the exporter sends traces only to the collector to eliminate the duplicate entries.
Usage¶
from opentelemetry import trace
from opentelemetry.exporter.jaeger.thrift import JaegerExporter
from opentelemetry.sdk.resources import SERVICE_NAME, Resource
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
trace.set_tracer_provider(
TracerProvider(
resource=Resource.create({SERVICE_NAME: "my-helloworld-service"})
)
)
tracer = trace.get_tracer(__name__)
# create a JaegerExporter
jaeger_exporter = JaegerExporter(
# configure agent
agent_host_name='localhost',
agent_port=6831,
# optional: configure also collector
# collector_endpoint='http://localhost:14268/api/traces?format=jaeger.thrift',
# username=xxxx, # optional
# password=xxxx, # optional
# max_tag_value_length=None # optional
)
# Create a BatchSpanProcessor and add the exporter to it
span_processor = BatchSpanProcessor(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!')
You can configure the exporter with the following environment variables:
API¶
-
class
opentelemetry.exporter.jaeger.thrift.
JaegerExporter
(agent_host_name=None, agent_port=None, collector_endpoint=None, username=None, password=None, max_tag_value_length=None, udp_split_oversized_batches=None, timeout=None)[source]¶ Bases:
opentelemetry.sdk.trace.export.SpanExporter
Jaeger span exporter for OpenTelemetry.
- Parameters
agent_host_name (
Optional
[str
]) – The host name of the Jaeger-Agent.collector_endpoint (
Optional
[str
]) – The endpoint of the Jaeger collector that uses Thrift over HTTP/HTTPS.username (
Optional
[str
]) – The user name of the Basic Auth if authentication is required.password (
Optional
[str
]) – The password of the Basic Auth if authentication is required.max_tag_value_length (
Optional
[int
]) – Max length string attribute values can have. Set to None to disable.udp_split_oversized_batches (
Optional
[bool
]) – Re-emit oversized batches in smaller chunks.timeout (
Optional
[int
]) – Maximum time the Jaeger exporter should wait for each batch export.
-
export
(spans)[source]¶ Exports a batch of telemetry data.
- Parameters
spans – The list of
opentelemetry.trace.Span
objects to be exported- Return type
- Returns
The result of the export
OpenTelemetry Jaeger Protobuf Exporter¶
The OpenTelemetry Jaeger Protobuf Exporter allows to export OpenTelemetry traces to Jaeger. This exporter always sends traces to the configured agent using Protobuf via gRPC.
Usage¶
from opentelemetry import trace
from opentelemetry.exporter.jaeger.proto.grpc import JaegerExporter
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
trace.set_tracer_provider(TracerProvider())
tracer = trace.get_tracer(__name__)
# create a JaegerExporter
jaeger_exporter = JaegerExporter(
# optional: configure collector
# collector_endpoint='localhost:14250',
# insecure=True, # optional
# credentials=xxx # optional channel creds
# max_tag_value_length=None # optional
)
# Create a BatchSpanProcessor and add the exporter to it
span_processor = BatchSpanProcessor(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!')
You can configure the exporter with the following environment variables:
API¶
-
class
opentelemetry.exporter.jaeger.proto.grpc.
JaegerExporter
(collector_endpoint=None, insecure=None, credentials=None, max_tag_value_length=None, timeout=None)[source]¶ Bases:
opentelemetry.sdk.trace.export.SpanExporter
Jaeger span exporter for OpenTelemetry.
- Parameters
collector_endpoint (
Optional
[str
]) – The endpoint of the Jaeger collector that uses Protobuf via gRPC.insecure (
Optional
[bool
]) – True if collector has no encryption or authenticationcredentials (
Optional
[ChannelCredentials
]) – Credentials for server authentication.max_tag_value_length (
Optional
[int
]) – Max length string attribute values can have. Set to None to disable.timeout (
Optional
[int
]) – Maximum time the Jaeger exporter should wait for each batch export.
-
export
(spans)[source]¶ Exports a batch of telemetry data.
- Parameters
spans – The list of
opentelemetry.trace.Span
objects to be exported- Return type
- Returns
The result of the export
Submodules¶
-
class
opentelemetry.exporter.jaeger.thrift.gen.jaeger.ttypes.
TagType
[source]¶ Bases:
object
-
STRING
= 0¶
-
DOUBLE
= 1¶
-
BOOL
= 2¶
-
LONG
= 3¶
-
BINARY
= 4¶
-
-
class
opentelemetry.exporter.jaeger.thrift.gen.jaeger.ttypes.
SpanRefType
[source]¶ Bases:
object
-
CHILD_OF
= 0¶
-
FOLLOWS_FROM
= 1¶
-
-
class
opentelemetry.exporter.jaeger.thrift.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))¶
-
-
class
opentelemetry.exporter.jaeger.thrift.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.exporter.jaeger.thrift.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))¶
-
-
class
opentelemetry.exporter.jaeger.thrift.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))¶
-
-
class
opentelemetry.exporter.jaeger.thrift.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.exporter.jaeger.thrift.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.exporter.jaeger.thrift.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.exporter.jaeger.thrift.gen.jaeger.ttypes.Log'>, (None, (1, 10, 'timestamp', None, None), (2, 15, 'fields', (12, (<class 'opentelemetry.exporter.jaeger.thrift.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))¶
-
-
class
opentelemetry.exporter.jaeger.thrift.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.exporter.jaeger.thrift.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))¶
-
-
class
opentelemetry.exporter.jaeger.thrift.gen.jaeger.ttypes.
Batch
(process=None, spans=None)[source]¶ Bases:
object
-
- process
-
- spans
-
thrift_spec
= (None, (1, 12, 'process', (<class 'opentelemetry.exporter.jaeger.thrift.gen.jaeger.ttypes.Process'>, (None, (1, 11, 'serviceName', 'UTF8', None), (2, 15, 'tags', (12, (<class 'opentelemetry.exporter.jaeger.thrift.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.exporter.jaeger.thrift.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.exporter.jaeger.thrift.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.exporter.jaeger.thrift.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.exporter.jaeger.thrift.gen.jaeger.ttypes.Log'>, (None, (1, 10, 'timestamp', None, None), (2, 15, 'fields', (12, (<class 'opentelemetry.exporter.jaeger.thrift.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))¶
-
-
class
opentelemetry.exporter.jaeger.thrift.gen.jaeger.ttypes.
BatchSubmitResponse
(ok=None)[source]¶ Bases:
object
-
- ok
-
thrift_spec
= (None, (1, 2, 'ok', None, None))¶
-
-
class
opentelemetry.exporter.jaeger.thrift.send.
AgentClientUDP
(host_name, port, max_packet_size=65000, client=<class 'opentelemetry.exporter.jaeger.thrift.gen.agent.Agent.Client'>, split_oversized_batches=False)[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.
split_oversized_batches – Re-emit oversized batches in smaller chunks.
-
class
opentelemetry.exporter.jaeger.thrift.send.
Collector
(thrift_url='', auth=None, timeout_in_millis=None)[source]¶ Bases:
object
Submits collected spans to Jaeger collector in jaeger.thrift format over binary thrift protocol. This is recommend option in cases where it is not feasible to deploy Jaeger Agent next to the application, for example, when the application code is running as AWS Lambda function. In these scenarios the Jaeger Clients can be configured to submit spans directly to the Collectors over HTTP/HTTPS.
- Parameters
thrift_url – Endpoint used to send spans directly to Collector the over HTTP.
auth – Auth tuple that contains username and password for Basic Auth.
timeout_in_millis – timeout for THttpClient.
-
class
opentelemetry.exporter.jaeger.proto.grpc.gen.collector_pb2_grpc.
CollectorServiceStub
(channel)[source]¶ Bases:
object