opentelemetry-otlp
Version: 0.31.0 Theopentelemetry-otlp crate exports telemetry data (logs, metrics, and traces) using the OpenTelemetry Protocol (OTLP) to compatible backends including OpenTelemetry Collector, Jaeger, Prometheus, and vendor-specific endpoints.
Installation
Feature Flags
Signals:trace: Trace exporters (enabled by default)metrics: Metrics exporters (enabled by default)logs: Log exporters (enabled by default)
grpc-tonic: Use Tonic for gRPC transportgzip-tonic: gzip compression for Toniczstd-tonic: zstd compression for Tonictls-ring: TLS via rustls with ring cryptotls-aws-lc: TLS via rustls with AWS-LC cryptotls-roots: System trust roots via rustls-native-certstls-webpki-roots: Mozilla trust roots via webpki-roots
http-proto: HTTP with protobuf (enabled by default)http-json: HTTP with JSONgzip-http: gzip compression for HTTPzstd-http: zstd compression for HTTPreqwest-blocking-client: Reqwest blocking client (enabled by default)reqwest-client: Reqwest async clientreqwest-rustls: Reqwest with rustls TLSreqwest-rustls-webpki-roots: Reqwest with webpki rootshyper-client: Hyper client
Quick Start
HTTP Export to Collector
gRPC Export (Requires Tokio)
Exporters
Span Exporter
Exports trace spans via OTLP
Metric Exporter
Exports metrics via OTLP
Log Exporter
Exports log records via OTLP
Configuration
Protocol Selection
OTLP wire protocol format:
Grpc: gRPC transportHttpBinary: HTTP with protobuf encodingHttpJson: HTTP with JSON encoding
Compression
Compression algorithm:
Gzip: gzip compressionZstd: Zstandard compression
Environment Variables
The exporter respects standard OTLP environment variables:General (All Signals)
OTEL_EXPORTER_OTLP_ENDPOINT: Target URL (default:http://localhost:4318for HTTP,http://localhost:4317for gRPC)OTEL_EXPORTER_OTLP_PROTOCOL: Protocol (grpc,http/protobuf,http/json)OTEL_EXPORTER_OTLP_TIMEOUT: Timeout in milliseconds (default: 10000)OTEL_EXPORTER_OTLP_HEADERS: Request headers askey1=value1,key2=value2OTEL_EXPORTER_OTLP_COMPRESSION: Compression algorithm (gzip,zstd)
Signal-Specific
-
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT: Trace-specific endpoint -
OTEL_EXPORTER_OTLP_TRACES_HEADERS: Trace-specific headers -
OTEL_EXPORTER_OTLP_TRACES_TIMEOUT: Trace-specific timeout -
OTEL_EXPORTER_OTLP_TRACES_COMPRESSION: Trace-specific compression -
OTEL_EXPORTER_OTLP_METRICS_ENDPOINT: Metrics-specific endpoint -
OTEL_EXPORTER_OTLP_METRICS_HEADERS: Metrics-specific headers -
OTEL_EXPORTER_OTLP_METRICS_TIMEOUT: Metrics-specific timeout -
OTEL_EXPORTER_OTLP_METRICS_COMPRESSION: Metrics-specific compression -
OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE: Temporality (cumulative,delta,lowmemory) -
OTEL_EXPORTER_OTLP_LOGS_ENDPOINT: Logs-specific endpoint -
OTEL_EXPORTER_OTLP_LOGS_HEADERS: Logs-specific headers -
OTEL_EXPORTER_OTLP_LOGS_TIMEOUT: Logs-specific timeout -
OTEL_EXPORTER_OTLP_LOGS_COMPRESSION: Logs-specific compression
Use with Popular Backends
OpenTelemetry Collector
Jaeger (with OTLP support)
http://localhost:16686
Prometheus (with OTLP receiver)
http://localhost:9090
Related Crates
- opentelemetry - Core API
- opentelemetry-sdk - SDK implementation
Documentation
Full API Documentation
View complete API reference on docs.rs