Prerequisites
Minimum Rust version: 1.75 or later
Basic installation
Add the core OpenTelemetry dependencies to yourCargo.toml:
Choose an exporter
Select an exporter based on your observability backend:OTLP (recommended for production)
The OTLP exporter supports HTTP and gRPC protocols for sending telemetry to the OpenTelemetry Collector or OTLP-compatible backends:Stdout (for development and debugging)
Export telemetry to stdout for local development:Cargo.toml
Prometheus
Export metrics to Prometheus:Cargo.toml
Zipkin
Export traces to Zipkin:Cargo.toml
Log appenders
Add a log appender to route logs to OpenTelemetry:Common dependency combinations
Here are complete examples for common use cases:Full stack with OTLP (HTTP)
Cargo.toml
Development with stdout
Cargo.toml
Metrics only with Prometheus
Cargo.toml
Optional features
Configure additional features as needed:Compression (OTLP)
Enable compression for OTLP exports:Cargo.toml
gzip-http- gzip compression for HTTPzstd-http- zstd compression for HTTPgzip-tonic- gzip compression for gRPCzstd-tonic- zstd compression for gRPC
TLS support (gRPC)
Enable TLS for gRPC connections:Cargo.toml
tls-ring- TLS using ring cryptotls-aws-lc- TLS using AWS libcryptotls-roots- Use native certificate rootstls-webpki-roots- Use webpki certificate roots
Retry support
Enable automatic retry for failed exports:Verify installation
Build your project to verify all dependencies are installed correctly:Next steps
Quickstart
Try a complete working example with traces, metrics, or logs