OpenTelemetry Datadog Exporter¶
from opentelemetry import trace from opentelemetry.ext.datadog import DatadogExportSpanProcessor, DatadogSpanExporter from opentelemetry.sdk.trace import TracerProvider trace.set_tracer_provider(TracerProvider()) tracer = trace.get_tracer(__name__) exporter = DatadogSpanExporter( agent_url="http://agent:8126", service="my-helloworld-service" ) span_processor = DatadogExportSpanProcessor(exporter) trace.get_tracer_provider().add_span_processor(span_processor) with tracer.start_as_current_span("foo"): print("Hello world!")
Datadog span exporter for OpenTelemetry.
agent_url – The url of the Datadog Agent or use
service – The service to be used for the application or use
Exports a batch of telemetry data.
spans – The list of
opentelemetry.trace.Spanobjects to be exported
The result of the export
Shuts down the exporter.
Called when the SDK is shut down.
DatadogExportSpanProcessor(span_exporter, schedule_delay_millis=5000, max_trace_size=4096)¶
Datadog exporter span processor
DatadogExportSpanProcessor is an implementation of
SpanProcessorthat batches all opened spans into a list per trace. When all spans for a trace are ended, the trace is queues up for export. This is required for exporting to the Datadog Agent which expects to received list of spans for each trace.
Called when a
This method is called synchronously on the thread that starts the span, therefore it should not block or throw an exception.
Called when a
This method is called synchronously on the thread that ends the span, therefore it should not block or throw an exception.
Exports traces with finished spans.
- Return type
Export all ended spans to the configured Exporter that have not yet been exported.