From bd5ce472ad52a6b9b98db2a420d28e6105b87ffc Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Tue, 19 Nov 2024 10:46:24 +0100 Subject: [PATCH] Upgrade to opentelemetry 0.27 --- Cargo.lock | 22 ++++++++++++---------- Cargo.toml | 8 ++++---- src/cli/log.rs | 25 +++++++++++++------------ 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d5596529f5..5a43d9781b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1720,9 +1720,9 @@ dependencies = [ [[package]] name = "opentelemetry" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "570074cc999d1a58184080966e5bd3bf3a9a4af650c3b05047c2621e7405cd17" +checksum = "0f3cebff57f7dbd1255b44d8bddc2cebeb0ea677dbaa2e25a3070a91b318f660" dependencies = [ "futures-core", "futures-sink", @@ -1734,9 +1734,9 @@ dependencies = [ [[package]] name = "opentelemetry-otlp" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29e1f9c8b032d4f635c730c0efcf731d5e2530ea13fa8bef7939ddc8420696bd" +checksum = "91cf61a1868dacc576bf2b2a1c3e9ab150af7272909e80085c3173384fe11f76" dependencies = [ "async-trait", "futures-core", @@ -1748,13 +1748,14 @@ dependencies = [ "thiserror 1.0.69", "tokio", "tonic", + "tracing", ] [[package]] name = "opentelemetry-proto" -version = "0.26.1" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c9d3968ce3aefdcca5c27e3c4ea4391b37547726a70893aab52d3de95d5f8b34" +checksum = "a6e05acbfada5ec79023c85368af14abd0b307c015e9064d249b2a950ef459a6" dependencies = [ "opentelemetry", "opentelemetry_sdk", @@ -1764,9 +1765,9 @@ dependencies = [ [[package]] name = "opentelemetry_sdk" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2c627d9f4c9cdc1f21a29ee4bfbd6028fcb8bcf2a857b43f3abdf72c9c862f3" +checksum = "27b742c1cae4693792cc564e58d75a2a0ba29421a34a85b50da92efa89ecb2bc" dependencies = [ "async-trait", "futures-channel", @@ -1781,6 +1782,7 @@ dependencies = [ "thiserror 1.0.69", "tokio", "tokio-stream", + "tracing", ] [[package]] @@ -3019,9 +3021,9 @@ dependencies = [ [[package]] name = "tracing-opentelemetry" -version = "0.27.0" +version = "0.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc58af5d3f6c5811462cabb3289aec0093f7338e367e5a33d28c0433b3c7360b" +checksum = "97a971f6058498b5c0f1affa23e7ea202057a7301dbff68e968b2d578bcbd053" dependencies = [ "js-sys", "once_cell", diff --git a/Cargo.toml b/Cargo.toml index 52b786abd2..e33ce56da7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -144,9 +144,9 @@ license = "MIT OR Apache-2.0" [workspace.dependencies] anyhow = "1.0.69" fs_at = "0.2.1" -opentelemetry = "0.26" -opentelemetry-otlp = "0.26" -opentelemetry_sdk = { version = "0.26", features = ["rt-tokio"] } +opentelemetry = "0.27" +opentelemetry-otlp = "0.27" +opentelemetry_sdk = { version = "0.27", features = ["rt-tokio"] } platforms = "3.4" proptest = "1.1.0" tempfile = "3.8" @@ -156,7 +156,7 @@ tokio = { version = "1.26.0", default-features = false, features = ["macros", "r tokio-retry = { version = "0.3.0" } tokio-stream = { version = "0.1.14" } tracing = "0.1" -tracing-opentelemetry = "0.27" +tracing-opentelemetry = "0.28" tracing-subscriber = "0.3.16" url = "2.4" walkdir = "2" diff --git a/src/cli/log.rs b/src/cli/log.rs index 5db2bb0b53..e307bfe8c6 100644 --- a/src/cli/log.rs +++ b/src/cli/log.rs @@ -152,27 +152,28 @@ where fn telemetry_default_tracer() -> Tracer { use std::time::Duration; - use opentelemetry::{global, trace::TracerProvider, KeyValue}; + use opentelemetry::{global, trace::TracerProvider as _, KeyValue}; use opentelemetry_otlp::WithExportConfig; use opentelemetry_sdk::{ - trace::{Config, Sampler}, + runtime::Tokio, + trace::{Config, Sampler, TracerProvider}, Resource, }; - let provider = opentelemetry_otlp::new_pipeline() - .tracing() - .with_exporter( - opentelemetry_otlp::new_exporter() - .tonic() - .with_timeout(Duration::from_secs(3)), - ) - .with_trace_config( + let exporter = opentelemetry_otlp::SpanExporter::builder() + .with_tonic() + .with_timeout(Duration::from_secs(3)) + .build() + .unwrap(); + + let provider = TracerProvider::builder() + .with_config( Config::default() .with_sampler(Sampler::AlwaysOn) .with_resource(Resource::new(vec![KeyValue::new("service.name", "rustup")])), ) - .install_batch(opentelemetry_sdk::runtime::Tokio) - .expect("error installing `OtlpTracePipeline` in the current `tokio` runtime"); + .with_batch_exporter(exporter, Tokio) + .build(); global::set_tracer_provider(provider.clone()); provider.tracer("tracing-otel-subscriber")