> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/open-telemetry/opentelemetry-rust/llms.txt
> Use this file to discover all available pages before exploring further.

# Installation

> Add OpenTelemetry to your Rust project and configure dependencies for traces, metrics, and logs

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

<Note>
  **Minimum Rust version**: 1.75 or later
</Note>

Verify your Rust version:

```bash theme={null}
rustc --version
```

If you need to update Rust:

```bash theme={null}
rustup update stable
```

## Basic installation

Add the core OpenTelemetry dependencies to your `Cargo.toml`:

<CodeGroup>
  ```toml Cargo.toml (All signals) theme={null}
  [dependencies]
  opentelemetry = "0.31.0"
  opentelemetry_sdk = "0.31.0"
  ```

  ```toml Cargo.toml (Traces only) theme={null}
  [dependencies]
  opentelemetry = { version = "0.31.0", features = ["trace"] }
  opentelemetry_sdk = { version = "0.31.0", features = ["trace"] }
  ```

  ```toml Cargo.toml (Metrics only) theme={null}
  [dependencies]
  opentelemetry = { version = "0.31.0", features = ["metrics"] }
  opentelemetry_sdk = { version = "0.31.0", features = ["metrics"] }
  ```

  ```toml Cargo.toml (Logs only) theme={null}
  [dependencies]
  opentelemetry = { version = "0.31.0", features = ["logs"] }
  opentelemetry_sdk = { version = "0.31.0", features = ["logs"] }
  ```
</CodeGroup>

<Tip>
  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.
</Tip>

## 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:

<CodeGroup>
  ```toml HTTP (default) theme={null}
  [dependencies]
  opentelemetry = "0.31.0"
  opentelemetry_sdk = "0.31.0"
  opentelemetry-otlp = { version = "0.31.0", features = ["http-proto", "reqwest-blocking-client"] }
  ```

  ```toml gRPC theme={null}
  [dependencies]
  opentelemetry = "0.31.0"
  opentelemetry_sdk = "0.31.0"
  opentelemetry-otlp = { version = "0.31.0", features = ["grpc-tonic"] }
  tokio = { version = "1.0", features = ["full"] }
  ```

  ```toml HTTP with async runtime theme={null}
  [dependencies]
  opentelemetry = "0.31.0"
  opentelemetry_sdk = "0.31.0"
  opentelemetry-otlp = { version = "0.31.0", features = ["http-proto", "reqwest-client"] }
  tokio = { version = "1.0", features = ["full"] }
  ```
</CodeGroup>

### Stdout (for development and debugging)

Export telemetry to stdout for local development:

```toml Cargo.toml theme={null}
[dependencies]
opentelemetry = "0.31.0"
opentelemetry_sdk = "0.31.0"
opentelemetry-stdout = "0.31.0"
tokio = { version = "1.0", features = ["full"] }
```

### Prometheus

Export metrics to Prometheus:

```toml Cargo.toml theme={null}
[dependencies]
opentelemetry = { version = "0.31.0", features = ["metrics"] }
opentelemetry_sdk = { version = "0.31.0", features = ["metrics"] }
opentelemetry-prometheus = "0.31.0"
prometheus = "0.13"
```

### Zipkin

Export traces to Zipkin:

```toml Cargo.toml theme={null}
[dependencies]
opentelemetry = { version = "0.31.0", features = ["trace"] }
opentelemetry_sdk = { version = "0.31.0", features = ["trace"] }
opentelemetry-zipkin = "0.31.0"
```

## Log appenders

<Warning>
  OpenTelemetry Rust does not provide a new logging API. Use an appender to bridge existing logging libraries to OpenTelemetry.
</Warning>

Add a log appender to route logs to OpenTelemetry:

<CodeGroup>
  ```toml Tracing (recommended) theme={null}
  [dependencies]
  opentelemetry = { version = "0.31.0", features = ["logs"] }
  opentelemetry_sdk = { version = "0.31.0", features = ["logs"] }
  opentelemetry-appender-tracing = "0.31.0"
  tracing = "0.1"
  tracing-subscriber = { version = "0.3", features = ["registry", "std"] }
  ```

  ```toml Log crate theme={null}
  [dependencies]
  opentelemetry = { version = "0.31.0", features = ["logs"] }
  opentelemetry_sdk = { version = "0.31.0", features = ["logs"] }
  opentelemetry-appender-log = "0.31.0"
  log = "0.4"
  ```
</CodeGroup>

<Tip>
  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.
</Tip>

## Common dependency combinations

Here are complete examples for common use cases:

### Full stack with OTLP (HTTP)

```toml Cargo.toml theme={null}
[dependencies]
opentelemetry = "0.31.0"
opentelemetry_sdk = "0.31.0"
opentelemetry-otlp = { version = "0.31.0", features = ["http-proto", "reqwest-blocking-client"] }
opentelemetry-appender-tracing = "0.31.0"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["registry", "std"] }
tokio = { version = "1.0", features = ["full"] }
```

### Development with stdout

```toml Cargo.toml theme={null}
[dependencies]
opentelemetry = "0.31.0"
opentelemetry_sdk = "0.31.0"
opentelemetry-stdout = "0.31.0"
opentelemetry-appender-tracing = "0.31.0"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["registry", "std"] }
tokio = { version = "1.0", features = ["full"] }
once_cell = "1.0"
```

### Metrics only with Prometheus

```toml Cargo.toml theme={null}
[dependencies]
opentelemetry = { version = "0.31.0", features = ["metrics"] }
opentelemetry_sdk = { version = "0.31.0", features = ["metrics"] }
opentelemetry-prometheus = "0.31.0"
prometheus = "0.13"
tokio = { version = "1.0", features = ["full"] }
```

## Optional features

Configure additional features as needed:

### Compression (OTLP)

Enable compression for OTLP exports:

```toml Cargo.toml theme={null}
[dependencies]
opentelemetry-otlp = { version = "0.31.0", features = ["http-proto", "gzip-http"] }
```

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:

```toml Cargo.toml theme={null}
[dependencies]
opentelemetry-otlp = { version = "0.31.0", features = ["grpc-tonic", "tls-ring"] }
```

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:

<CodeGroup>
  ```toml HTTP with retry theme={null}
  [dependencies]
  opentelemetry-otlp = { version = "0.31.0", features = ["http-proto", "experimental-http-retry"] }
  opentelemetry_sdk = { version = "0.31.0", features = ["rt-tokio"] }
  tokio = { version = "1.0", features = ["full"] }
  ```

  ```toml gRPC with retry theme={null}
  [dependencies]
  opentelemetry-otlp = { version = "0.31.0", features = ["grpc-tonic", "experimental-grpc-retry"] }
  opentelemetry_sdk = { version = "0.31.0", features = ["rt-tokio"] }
  tokio = { version = "1.0", features = ["full"] }
  ```
</CodeGroup>

## Verify installation

Build your project to verify all dependencies are installed correctly:

```bash theme={null}
cargo build
```

If you encounter any dependency resolution issues, try updating your dependencies:

```bash theme={null}
cargo update
```

## Next steps

<Card title="Quickstart" icon="bolt" href="/quickstart">
  Try a complete working example with traces, metrics, or logs
</Card>
