opentelemetry-rust

Configure OpenTelemetry traces, metrics, and logs instrumentation for Rust services.

2|Updated May 16, 2026
One-click install
npx skills add https://github.com/avbel/ai-skills --skill opentelemetry-rust-avbel
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: opentelemetry-rust
Source: https://github.com/avbel/ai-skills/tree/main/skills/opentelemetry-rust
Command: npx skills add https://github.com/avbel/ai-skills --skill opentelemetry-rust-avbel

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve? Rust developers instrumenting services with OpenTelemetry face version mismatches between core and companion crates, unclear exporter configuration, and subtle pitfalls like dropped observable instrument handles that cause memory growth. This Skill provides version-aligned conventions and working code patterns for the opentelemetry-rust ecosystem. ## Core Features & Use Cases - Version-aligned crate guidance: Pins compatible combinations of opentelemetry, opentelemetry_sdk, opentelemetry-otlp, and lagging companion crates like opentelemetry-stdout and opentelemetry-appender-tracing. - Production telemetry patterns: Covers OTLP HTTP/gRPC exporters, batch processors, resource attributes, propagation, sampling, and graceful provider shutdown. - Starter snippet generator: A bootstrap script prints JSON with Cargo dependencies and code snippets for stdout traces, OTLP HTTP, metrics, manual spans, and observable instruments. - Use Case: When adding distributed tracing to an axum or tokio service, use this Skill to wire an OTLP exporter with correct endpoints, service.name resources, and shutdown handling without mixing incompatible crate versions. ## Quick Start Ask the agent to set up OpenTelemetry tracing for a Rust service with an OTLP HTTP exporter and graceful shutdown using the opentelemetry-rust conventions.

Frequently Asked Questions about opentelemetry-rust

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

FAQPage Schema
How do I set up OpenTelemetry tracing in a Rust application?▼

Build an SdkTracerProvider with a Resource containing your service name and an exporter, then create spans with a tracer. Use a simple exporter for local tests and a batch exporter for production, and call shutdown() on the provider during graceful shutdown.

How do I export Rust OpenTelemetry data over OTLP HTTP?▼

Use opentelemetry-otlp with the http-proto feature and build a SpanExporter via .with_http() pointing at a signal-specific endpoint like http://localhost:4318/v1/traces. Default OTLP HTTP port is 4318 and gRPC is 4317.

Which opentelemetry-rust crate versions are compatible together?▼

The core opentelemetry, opentelemetry_sdk, and opentelemetry-otlp crates are aligned at 0.32, while opentelemetry-stdout and opentelemetry-appender-tracing lag at 0.31. Do not mix 0.31 companion crates with a 0.32 SDK unless compatibility is verified.

Why does my Rust OpenTelemetry metrics pipeline grow in memory?▼

Dropping observable instrument handles can unregister instruments and cause SDK pipeline memory growth. Keep the handles returned by .build() alive for the process lifetime, bind them to named variables rather than bare underscores, and drop them only after provider shutdown.

Should Rust libraries depend on opentelemetry_sdk?▼

No. Library crates should depend only on the opentelemetry API crate, which acts as a no-op facade until an SDK is installed. Applications add opentelemetry_sdk and exporter crates such as opentelemetry-otlp or opentelemetry-stdout.