OpenTelemetry Collector Exporters for sending telemetry data via OTLP protocol
npx @tessl/cli install tessl/pypi-opentelemetry-exporter-otlp@1.36.0A convenient meta-package that provides all supported OpenTelemetry Collector Exporters for Python applications. This package acts as an umbrella installation that includes both opentelemetry-exporter-otlp-proto-grpc and opentelemetry-exporter-otlp-proto-http dependencies, enabling developers to easily install and use OTLP (OpenTelemetry Protocol) exporters for sending telemetry data (traces, metrics, and logs) to OpenTelemetry Collector endpoints.
Important: This package registers only gRPC exporters as entry points for the OpenTelemetry SDK. HTTP exporters are available through direct imports but are not registered as SDK entry points.
pip install opentelemetry-exporter-otlpfrom opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
from opentelemetry.exporter.otlp.proto.grpc.metric_exporter import OTLPMetricExporter
from opentelemetry.exporter.otlp.proto.grpc._log_exporter import OTLPLogExporterfrom opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.exporter.otlp.proto.http.metric_exporter import OTLPMetricExporter
from opentelemetry.exporter.otlp.proto.http._log_exporter import OTLPLogExporterNote: Both gRPC and HTTP exporters use the same class names. Import from the appropriate module based on your protocol preference.
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
from opentelemetry.exporter.otlp.proto.grpc.metric_exporter import OTLPMetricExporter
from opentelemetry.exporter.otlp.proto.grpc._log_exporter import OTLPLogExporter
# Create exporters with default settings (localhost:4317)
span_exporter = OTLPSpanExporter()
metric_exporter = OTLPMetricExporter()
log_exporter = OTLPLogExporter()
# Create exporters with custom endpoint
span_exporter = OTLPSpanExporter(
endpoint="https://my-collector:4317",
headers={"api-key": "your-api-key"}
)from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter
from opentelemetry.exporter.otlp.proto.http.metric_exporter import OTLPMetricExporter
from opentelemetry.exporter.otlp.proto.http._log_exporter import OTLPLogExporter
# Create exporters with default settings (localhost:4318)
span_exporter = OTLPSpanExporter()
metric_exporter = OTLPMetricExporter()
log_exporter = OTLPLogExporter()
# Create exporters with custom endpoint and SSL
span_exporter = OTLPSpanExporter(
endpoint="https://my-collector:4318/v1/traces",
headers={"Authorization": "Bearer token"},
certificate_file="/path/to/cert.pem"
)This meta-package aggregates functionality from two main dependencies:
Each protocol supports three types of exporters:
The package registers the following entry points for OpenTelemetry SDK integration:
opentelemetry_traces_exporter.otlp: gRPC OTLPSpanExporteropentelemetry_metrics_exporter.otlp: gRPC OTLPMetricExporteropentelemetry_logs_exporter.otlp: gRPC OTLPLogExporterNote: Only gRPC exporters are registered as entry points. HTTP exporters must be imported and configured directly.
All exporters implement the OpenTelemetry Protocol (OTLP) specification and support environment variable configuration following OpenTelemetry standards.
OTLP exporters using gRPC protocol with protobuf serialization. These exporters provide efficient binary protocol communication with OpenTelemetry Collector endpoints.
class OTLPSpanExporter:
def __init__(self, endpoint=None, insecure=None, credentials=None, headers=None, timeout=None, compression=None, channel_options=None): ...
def export(self, spans): ...
def shutdown(self): ...
def force_flush(self): ...
class OTLPMetricExporter:
def __init__(self, endpoint=None, insecure=None, credentials=None, headers=None, timeout=None, compression=None, preferred_temporality=None, preferred_aggregation=None, max_export_batch_size=None, channel_options=None): ...
def export(self, metrics): ...
def shutdown(self): ...
def force_flush(self): ...
class OTLPLogExporter:
def __init__(self, endpoint=None, insecure=None, credentials=None, headers=None, timeout=None, compression=None, channel_options=None): ...
def export(self, logs): ...
def shutdown(self): ...
def force_flush(self): ...OTLP exporters using HTTP protocol with protobuf serialization. These exporters provide HTTP-based communication with OpenTelemetry Collector endpoints, suitable for environments where HTTP is preferred over gRPC.
class OTLPSpanExporter:
def __init__(self, endpoint=None, certificate_file=None, client_key_file=None, client_certificate_file=None, headers=None, timeout=None, compression=None, session=None): ...
def export(self, spans): ...
def shutdown(self): ...
def force_flush(self): ...
class OTLPMetricExporter:
def __init__(self, endpoint=None, certificate_file=None, client_key_file=None, client_certificate_file=None, headers=None, timeout=None, compression=None, session=None, preferred_temporality=None, preferred_aggregation=None): ...
def export(self, metrics): ...
def shutdown(self): ...
def force_flush(self): ...
class OTLPLogExporter:
def __init__(self, endpoint=None, certificate_file=None, client_key_file=None, client_certificate_file=None, headers=None, timeout=None, compression=None, session=None): ...
def export(self, logs): ...
def shutdown(self): ...
def force_flush(self): ...All exporters support configuration via OpenTelemetry standard environment variables:
OTEL_EXPORTER_OTLP_* (applies to all exporters)OTEL_EXPORTER_OTLP_TRACES_* (trace-specific settings)OTEL_EXPORTER_OTLP_METRICS_* (metric-specific settings)OTEL_EXPORTER_OTLP_LOGS_* (log-specific settings)Common environment variables include:
OTEL_EXPORTER_OTLP_ENDPOINT: Base collector endpointOTEL_EXPORTER_OTLP_HEADERS: Authentication headersOTEL_EXPORTER_OTLP_TIMEOUT: Export timeoutOTEL_EXPORTER_OTLP_COMPRESSION: Compression algorithmFor proper type annotations and usage, import the following when using the exporters:
# Return types
from opentelemetry.sdk.trace.export import SpanExportResult
from opentelemetry.sdk.metrics.export import MetricExportResult
from opentelemetry.sdk._logs._internal.export import LogExportResult
# gRPC types
import grpc
from grpc import ChannelCredentials, Compression as GrpcCompression
# HTTP types
import requests
from opentelemetry.exporter.otlp.proto.http import Compression# HTTP Compression enumeration
class Compression:
NoCompression = "none"
Deflate = "deflate"
Gzip = "gzip"
# Export result types
class SpanExportResult:
"""Result of span export operation."""
SUCCESS = 0
FAILURE = 1
class MetricExportResult:
"""Result of metric export operation."""
SUCCESS = 0
FAILURE = 1
class LogExportResult:
"""Result of log export operation."""
SUCCESS = 0
FAILURE = 1