nat.plugins.opentelemetry.otlp_span_adapter_exporter#

Attributes#

Classes#

OTLPSpanAdapterExporter

An OpenTelemetry OTLP span exporter for sending traces to OTLP-compatible services.

Module Contents#

logger#
class OTLPSpanAdapterExporter(
*,
context_state: nat.builder.context.ContextState | None = None,
batch_size: int = 100,
flush_interval: float = 5.0,
max_queue_size: int = 1000,
drop_on_overflow: bool = False,
shutdown_timeout: float = 10.0,
resource_attributes: dict[str, str] | None = None,
endpoint: str,
headers: dict[str, str] | None = None,
**otlp_kwargs,
)#

Bases: nat.plugins.opentelemetry.mixin.otlp_span_exporter_mixin.OTLPSpanExporterMixin, nat.plugins.opentelemetry.otel_span_exporter.OtelSpanExporter

An OpenTelemetry OTLP span exporter for sending traces to OTLP-compatible services.

This class combines the OtelSpanExporter base functionality with OTLP-specific export capabilities to provide a complete solution for sending telemetry traces to any OTLP-compatible collector or service via HTTP.

Key Features: - Complete span processing pipeline (IntermediateStep → Span → OtelSpan → Export) - Batching support for efficient transmission - OTLP HTTP protocol for maximum compatibility - Configurable authentication via headers - Resource attribute management - Error handling and retry logic

This exporter is commonly used with services like: - OpenTelemetry Collector - Jaeger (OTLP endpoint) - Grafana Tempo - Custom OTLP-compatible backends

Example:

exporter = OTLPSpanAdapterExporter(
    endpoint="https://api.service.com/v1/traces",
    headers={"Authorization": "Bearer your-token"},
    batch_size=50,
    flush_interval=10.0
)

Initialize the OTLP span exporter.

Args:

context_state: The context state for the exporter. batch_size: Number of spans to batch before exporting. flush_interval: Time in seconds between automatic batch flushes. max_queue_size: Maximum number of spans to queue. drop_on_overflow: Whether to drop spans when queue is full. shutdown_timeout: Maximum time to wait for export completion during shutdown. resource_attributes: Additional resource attributes for spans. endpoint: The endpoint for the OTLP service. headers: The headers for the OTLP service. otlp_kwargs: Additional keyword arguments for the OTLP service.