or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

grpc-exporters.mdhttp-exporters.mdindex.md
tile.json

tessl/pypi-opentelemetry-exporter-otlp

OpenTelemetry Collector Exporters for sending telemetry data via OTLP protocol

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/opentelemetry-exporter-otlp@1.36.x

To install, run

npx @tessl/cli install tessl/pypi-opentelemetry-exporter-otlp@1.36.0

index.mddocs/

OpenTelemetry OTLP Exporter

A 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.

Package Information

  • Package Name: opentelemetry-exporter-otlp
  • Language: Python
  • Installation: pip install opentelemetry-exporter-otlp

Core Imports

gRPC Exporters

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

HTTP Exporters

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

Note: Both gRPC and HTTP exporters use the same class names. Import from the appropriate module based on your protocol preference.

Basic Usage

Using gRPC Exporters

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"}
)

Using HTTP Exporters

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"
)

Architecture

This meta-package aggregates functionality from two main dependencies:

  • opentelemetry-exporter-otlp-proto-grpc: Provides gRPC-based exporters
  • opentelemetry-exporter-otlp-proto-http: Provides HTTP-based exporters

Each protocol supports three types of exporters:

  • Span Exporters: Export distributed tracing data
  • Metric Exporters: Export metrics and measurements
  • Log Exporters: Export structured log data

Entry Points Registration

The package registers the following entry points for OpenTelemetry SDK integration:

  • opentelemetry_traces_exporter.otlp: gRPC OTLPSpanExporter
  • opentelemetry_metrics_exporter.otlp: gRPC OTLPMetricExporter
  • opentelemetry_logs_exporter.otlp: gRPC OTLPLogExporter

Note: 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.

Capabilities

gRPC Protocol Exporters

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): ...

gRPC Exporters

HTTP Protocol Exporters

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): ...

HTTP Exporters

Environment Variables

All exporters support configuration via OpenTelemetry standard environment variables:

  • General: OTEL_EXPORTER_OTLP_* (applies to all exporters)
  • Traces: OTEL_EXPORTER_OTLP_TRACES_* (trace-specific settings)
  • Metrics: OTEL_EXPORTER_OTLP_METRICS_* (metric-specific settings)
  • Logs: OTEL_EXPORTER_OTLP_LOGS_* (log-specific settings)

Common environment variables include:

  • OTEL_EXPORTER_OTLP_ENDPOINT: Base collector endpoint
  • OTEL_EXPORTER_OTLP_HEADERS: Authentication headers
  • OTEL_EXPORTER_OTLP_TIMEOUT: Export timeout
  • OTEL_EXPORTER_OTLP_COMPRESSION: Compression algorithm

Required Imports

For 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

Types

# 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