Skip to main content

opentelemetry-otlp

Version: 0.31.0 The opentelemetry-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)
Transport - gRPC (Tonic):
  • grpc-tonic: Use Tonic for gRPC transport
  • gzip-tonic: gzip compression for Tonic
  • zstd-tonic: zstd compression for Tonic
  • tls-ring: TLS via rustls with ring crypto
  • tls-aws-lc: TLS via rustls with AWS-LC crypto
  • tls-roots: System trust roots via rustls-native-certs
  • tls-webpki-roots: Mozilla trust roots via webpki-roots
Transport - HTTP:
  • http-proto: HTTP with protobuf (enabled by default)
  • http-json: HTTP with JSON
  • gzip-http: gzip compression for HTTP
  • zstd-http: zstd compression for HTTP
  • reqwest-blocking-client: Reqwest blocking client (enabled by default)
  • reqwest-client: Reqwest async client
  • reqwest-rustls: Reqwest with rustls TLS
  • reqwest-rustls-webpki-roots: Reqwest with webpki roots
  • hyper-client: Hyper client

Quick Start

HTTP Export to Collector

gRPC Export (Requires Tokio)

Exporters

Span Exporter

struct
Exports trace spans via OTLP

Metric Exporter

struct
Exports metrics via OTLP

Log Exporter

struct
Exports log records via OTLP

Configuration

Protocol Selection

enum
OTLP wire protocol format:
  • Grpc: gRPC transport
  • HttpBinary: HTTP with protobuf encoding
  • HttpJson: HTTP with JSON encoding

Compression

enum
Compression algorithm:
  • Gzip: gzip compression
  • Zstd: Zstandard compression

Environment Variables

The exporter respects standard OTLP environment variables:

General (All Signals)

  • OTEL_EXPORTER_OTLP_ENDPOINT: Target URL (default: http://localhost:4318 for HTTP, http://localhost:4317 for 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 as key1=value1,key2=value2
  • OTEL_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

OpenTelemetry Collector

Jaeger (with OTLP support)

View traces at http://localhost:16686

Prometheus (with OTLP receiver)

View metrics at http://localhost:9090

Documentation

Full API Documentation

View complete API reference on docs.rs

Minimum Rust Version

MSRV: 1.75.0