opentelemetry
Version: 0.31.0 Theopentelemetry crate is the core API for OpenTelemetry in Rust. It provides the foundational interfaces and types for instrumenting applications with telemetry data, including traces, metrics, and logs.
This crate provides API definitions only (no-op implementations). To actually collect and export telemetry, you need to use
opentelemetry-sdk along with exporters like opentelemetry-otlp.Installation
Feature Flags
trace: Includes the trace API (enabled by default)metrics: Includes the metrics API (enabled by default)logs: Includes the logs bridge API (enabled by default)internal-logs: Enables internal logging viatracing(enabled by default)
What’s Included
Context API
Manage and propagate execution context across async boundaries.Tracing API
Create distributed traces to track request flows:Metrics API
Record measurements about your service:Logs Bridge API
Propagators API
Share context across service boundaries using propagation standards like W3C Trace Context and Baggage.Core Types
Carries execution-scoped values across API boundaries
Key-value pair for attributes on spans, metrics, and logs
Supported attribute value types: Bool, Int, Double, String, Array
Trace Types
Creates and manages spans
Represents a single operation within a trace
Creates
Tracer instances16-byte unique identifier for a trace
8-byte unique identifier for a span
Metrics Types
Creates metric instruments
Monotonically increasing metric
Records distribution of values
Records current value
Counter that can increase or decrease
Modules
global- Global API for tracer, meter, and propagator registrationtrace- Distributed tracing APImetrics- Metrics recording APIlogs- Logs bridge APIcontext- Context managementbaggage- Cross-cutting concerns propagationpropagation- Context propagation formats
Related Crates
- opentelemetry-sdk - SDK implementation
- opentelemetry-otlp - OTLP exporter
- opentelemetry-stdout - Stdout exporter for debugging
Documentation
Full API Documentation
View complete API reference on docs.rs