nat.plugins.opentelemetry.mixin.otlp_span_exporter_mixin#

Attributes#

Classes#

OTLPSpanExporterMixin

Mixin for OTLP span exporters.

Module Contents#

logger#
class OTLPSpanExporterMixin(
*args,
endpoint: str,
headers: dict[str, str] | None = None,
**kwargs,
)#

Mixin for OTLP span exporters.

This mixin provides OTLP-specific functionality for OpenTelemetry span exporters. It handles OTLP protocol transmission using the standard OpenTelemetry OTLP HTTP exporter.

Key Features: - Standard OTLP HTTP protocol support for span export - Configurable endpoint and headers for authentication/routing - Integration with OpenTelemetry’s OTLPSpanExporter for reliable transmission - Works with any OTLP-compatible collector or service

This mixin is designed to be used with OtelSpanExporter as a base class:

Example:

class MyOTLPExporter(OtelSpanExporter, OTLPSpanExporterMixin):
    def __init__(self, endpoint, headers, **kwargs):
        super().__init__(endpoint=endpoint, headers=headers, **kwargs)

Initialize the OTLP span exporter.

Args:

endpoint: OTLP service endpoint URL. headers: HTTP headers for authentication and metadata.

_exporter#
async export_otel_spans(
spans: list[nat.plugins.opentelemetry.otel_span.OtelSpan],
) None#

Export a list of OtelSpans using the OTLP exporter.

Args:

spans (list[OtelSpan]): The list of spans to export.

Raises:

Exception: If there’s an error during span export (logged but not re-raised).