Skip to main content
OpenTelemetry Rust is distributed as a collection of crates. Install the crates you need based on which telemetry signals (traces, metrics, logs) and exporters you want to use.

Prerequisites

Minimum Rust version: 1.75 or later
Verify your Rust version:
If you need to update Rust:

Basic installation

Add the core OpenTelemetry dependencies to your Cargo.toml:
By default, opentelemetry and opentelemetry_sdk include all signals (trace, metrics, logs). Use feature flags to reduce compile times and binary size if you only need specific signals.

Choose an exporter

Select an exporter based on your observability backend: 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

OpenTelemetry Rust does not provide a new logging API. Use an appender to bridge existing logging libraries to OpenTelemetry.
Add a log appender to route logs to OpenTelemetry:
If you’re starting a new project, use the tracing crate. It supports structured logging and is actively maintained. OpenTelemetry itself uses tracing for internal logging.

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
Available compression features:
  • gzip-http - gzip compression for HTTP
  • zstd-http - zstd compression for HTTP
  • gzip-tonic - gzip compression for gRPC
  • zstd-tonic - zstd compression for gRPC

TLS support (gRPC)

Enable TLS for gRPC connections:
Cargo.toml
Available TLS features:
  • tls-ring - TLS using ring crypto
  • tls-aws-lc - TLS using AWS libcrypto
  • tls-roots - Use native certificate roots
  • tls-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:
If you encounter any dependency resolution issues, try updating your dependencies:

Next steps

Quickstart

Try a complete working example with traces, metrics, or logs