opentelemetry-rust

Instrument Rust applications with OpenTelemetry SDK and OTLP exporters.

Updated Jan 28, 2026
One-click install
npx skills add https://github.com/cedricziel/claude-otel-plugin --skill opentelemetry-rust
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: opentelemetry-rust
Source: https://github.com/cedricziel/claude-otel-plugin/tree/main/.claude/skills/opentelemetry-rust
Command: npx skills add https://github.com/cedricziel/claude-otel-plugin --skill opentelemetry-rust

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides expert guidance for instrumenting Rust applications with OpenTelemetry, enabling you to add structured tracing, metrics, and telemetry using the official Rust SDK and OTLP exporters.

Core Features & Use Cases

  • Manual instrumentation with the OpenTelemetry Rust API to create spans and propagate context.
  • Metrics collection using the OpenTelemetry Rust SDK (counters, histograms, gauges) and OTLP exporters.
  • Integration with the tracing crate for structured logging and interoperability.
  • HTTP server/client instrumentation for frameworks like Axum, Actix-web, Rocket, and Tonic-based services.
  • Resource attributes and semantic conventions to standardize telemetry across services.
  • Production-ready patterns: context propagation, error recording, and exporter configuration for scalable observability.

Quick Start

  1. Add dependencies to Cargo.toml: [dependencies] opentelemetry = "0.27" opentelemetry-sdk = "0.27" opentelemetry-otlp = "0.27" tokio = { version = "1", features = ["full"] }
  2. Initialize tracer/provider at startup and set it as the global provider: use opentelemetry::{global, trace::Tracer}; // Build and install provider, then use global::set_tracer_provider(provider);
  3. Create a span around a work unit to instrument code: let tracer = global::tracer("my-service"); tracer.in_span("operation-name", |cx| { // your work here });

Frequently Asked Questions about opentelemetry-rust

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add tracing and metrics to a Rust web service?

Tracing and metrics in Rust are added using the OpenTelemetry SDK to instrument code with spans and collectors. Add opentelemetry, opentelemetry-sdk, and opentelemetry-otlp dependencies, initialize a tracer provider at startup, then wrap operations in spans using the tracer's in_span method to capture timing and context automatically.

Does OpenTelemetry work with Axum, Actix-web, and Rocket?

Yes, OpenTelemetry integrates with Axum, Actix-web, Rocket, and Tonic-based services through manual instrumentation of HTTP handlers and middleware. The Rust SDK provides the APIs to propagate context across requests and record spans for each operation these frameworks handle.

What's the best way to configure OTLP exporters for production observability in Rust?

Production-ready OTLP exporters in Rust require setting resource attributes, semantic conventions, proper context propagation across async tasks, and error recording in spans. Initialize the exporter with opentelemetry-otlp, configure the tracer provider globally, and ensure context flows through tokio tasks for complete distributed tracing.

How do I propagate context across async tasks in Rust observability?

Context propagation across async tasks uses OpenTelemetry's context API to attach trace and span IDs to tokio task spawns. Manually pass context through task boundaries or use instrumentation patterns that preserve the active span when tasks execute concurrently or in sequence.

Can I collect counters, histograms, and gauges with OpenTelemetry in Rust?

Yes, the OpenTelemetry Rust SDK supports metrics collection via counters, histograms, and gauges exported through OTLP. Define meters, create instruments for each metric type, record values during application execution, and export them to a metrics backend for aggregation and dashboarding.

Why should I use semantic conventions in Rust telemetry?

Semantic conventions standardize attribute naming and span naming across services, enabling consistent querying and correlation in observability backends. They ensure resource attributes and span metadata follow OpenTelemetry specifications, making traces and metrics portable and searchable across teams.