opentelemetry.sdk.trace.export
- class opentelemetry.sdk.trace.export.SpanExportResult(*values)[source]
Bases:
Enum- SUCCESS = 0
- FAILURE = 1
- class opentelemetry.sdk.trace.export.SpanExporter[source]
Bases:
objectInterface for exporting spans.
Interface to be implemented by services that want to export spans recorded in their own format.
To export data this MUST be registered to the :class`opentelemetry.sdk.trace.Tracer` using a
SimpleSpanProcessoror aBatchSpanProcessor.- export(spans)[source]
Exports a batch of telemetry data.
- Parameters:
spans (
Sequence[ReadableSpan]) – The list ofopentelemetry.trace.Spanobjects to be exported- Return type:
- Returns:
The result of the export
- class opentelemetry.sdk.trace.export.SimpleSpanProcessor(span_exporter, *, meter_provider=None)[source]
Bases:
SpanProcessorSimple SpanProcessor implementation.
SimpleSpanProcessor is an implementation of
SpanProcessorthat passes ended spans directly to the configuredSpanExporter.- on_start(span, parent_context=None)[source]
Called when a
opentelemetry.trace.Spanis started.This method is called synchronously on the thread that starts the span, therefore it should not block or throw an exception.
- Parameters:
span (
Span) – Theopentelemetry.trace.Spanthat just started.parent_context (
Optional[Context]) – The parent context of the span that just started.
- Return type:
- on_end(span)[source]
Called when a
opentelemetry.trace.Spanis ended.This method is called synchronously on the thread that ends the span, therefore it should not block or throw an exception.
- Parameters:
span (
ReadableSpan) – Theopentelemetry.trace.Spanthat just ended.- Return type:
- shutdown()[source]
Called when a
opentelemetry.sdk.trace.TracerProvideris shutdown.- Return type:
- class opentelemetry.sdk.trace.export.BatchSpanProcessor(span_exporter, max_queue_size=None, schedule_delay_millis=None, max_export_batch_size=None, export_timeout_millis=None, *, meter_provider=None)[source]
Bases:
SpanProcessorBatch span processor implementation.
BatchSpanProcessoris an implementation ofSpanProcessorthat batches ended spans and pushes them to the configuredSpanExporter.BatchSpanProcessoris configurable with the following environment variables which correspond to constructor parameters:All the logic for emitting spans, shutting down etc. resides in the
BatchProcessorclass.- property span_exporter
- on_start(span, parent_context=None)[source]
Called when a
opentelemetry.trace.Spanis started.This method is called synchronously on the thread that starts the span, therefore it should not block or throw an exception.
- Parameters:
span (
Span) – Theopentelemetry.trace.Spanthat just started.parent_context (
Context|None) – The parent context of the span that just started.
- Return type:
- on_end(span)[source]
Called when a
opentelemetry.trace.Spanis ended.This method is called synchronously on the thread that ends the span, therefore it should not block or throw an exception.
- Parameters:
span (
ReadableSpan) – Theopentelemetry.trace.Spanthat just ended.- Return type:
- shutdown()[source]
Called when a
opentelemetry.sdk.trace.TracerProvideris shutdown.
- class opentelemetry.sdk.trace.export.ConsoleSpanExporter(service_name=None, out=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, formatter=<function ConsoleSpanExporter.<lambda>>)[source]
Bases:
SpanExporterImplementation of
SpanExporterthat prints spans to the console.This class can be used for diagnostic purposes. It prints the exported spans to the console STDOUT.
- export(spans)[source]
Exports a batch of telemetry data.
- Parameters:
spans (
Sequence[ReadableSpan]) – The list ofopentelemetry.trace.Spanobjects to be exported- Return type:
- Returns:
The result of the export