| Crates.io | tracing-opentelemetry-setup |
| lib.rs | tracing-opentelemetry-setup |
| version | 0.5.1 |
| created_at | 2026-01-07 07:41:02.902387+00 |
| updated_at | 2026-01-23 04:59:50.766525+00 |
| description | Utilities to provide proper setup of tracing with OTEL export |
| homepage | |
| repository | https://github.com/DoumanAsh/tracing-opentelemetry-setup |
| max_upload_size | |
| id | 2027714 |
| size | 122,593 |
OpenTelemetry integration for tracing.
The goal of this crate is to provide all-in-one crate to initialize OpenTelemetry integration with tracing
MSRV 1.85
panic - Provides panic hook implementation. Must be enabled via panic modulepropagation - Enables propagation utilitiesmetrics - Enable integration with metricstracing-metrics - Enable metrics usage via tracing-opentelemetryrt-tokio - Tell OpenTelemetry sdk that you use tokio runtimedatadog - Enables datadog agent exporter. Currently supports only traces & logsgrpc - Enables tonic based gRPC transportgrpc-compression - Enables tonic based gRPC transport with compressiongrpc-tls - Enables tonic based gRPC transport with TLSNote that when enabling multiple clients, only one client will be used by default and it is up to opentelemetry-otlp
http - Enables http exporter code without specific client as default option.
http-compression - Enables http transport with compression
http-tls - Enables http transport with TLS
http-reqwest-blocking - Enables blocking reqwest client.
http-reqwest - Enables async reqwest client.
http-hyper - Enables hyper client.
Make sure tracing-opentelemetry-setup is installed to your dependencies
use tracing_opentelemetry_setup::{Otlp, tracing_subscriber, tracing};
use tracing_opentelemetry_setup::builder::{Destination, Protocol, Attributes, TraceSettings};
use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::util::SubscriberInitExt;
let default_attrs = Attributes::builder().with_attr("service.name", "サービス").finish();
let trace_settings = TraceSettings::new(1.0);
let destination = Destination {
protocol: Protocol::HttpBinary,
url: "http://localhost:45081".into()
};
let mut otlp = Otlp::builder(destination).with_header("Authorization", "Basic <my token>").with_trace(Some(&default_attrs), trace_settings).finish();
let registry = tracing_subscriber::registry().with(otlp.create_layer("tracing-opentelemetry".into())) //aggregates sdk providers into single layer
.with(tracing_subscriber::filter::LevelFilter::from_level(tracing::Level::INFO));
let _guard = registry.set_default();
//Do your job then shutdown to make sure you flush everything
otlp.shutdown(None).expect("successfully shut down OTLP")