From 00f1e7dec9bf771862392086482bacf5ecc921f3 Mon Sep 17 00:00:00 2001 From: Yeongju Kang Date: Fri, 27 Dec 2024 08:49:09 +0900 Subject: [PATCH] Bump the otel group with 4 updates and change builder functions Signed-off-by: Yeongju Kang --- Cargo.lock | 25 +++++++++++++------------ Cargo.toml | 8 ++++---- src/telemetry.rs | 13 ++++++------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 37736c1..0fb71ff 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1740,23 +1740,23 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "opentelemetry" -version = "0.26.0" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "570074cc999d1a58184080966e5bd3bf3a9a4af650c3b05047c2621e7405cd17" +checksum = "ab70038c28ed37b97d8ed414b6429d343a8bbf44c9f79ec854f3a643029ba6d7" dependencies = [ "futures-core", "futures-sink", "js-sys", - "once_cell", "pin-project-lite", "thiserror 1.0.69", + "tracing", ] [[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", @@ -1768,13 +1768,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", @@ -1784,16 +1785,15 @@ dependencies = [ [[package]] name = "opentelemetry_sdk" -version = "0.26.0" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2c627d9f4c9cdc1f21a29ee4bfbd6028fcb8bcf2a857b43f3abdf72c9c862f3" +checksum = "231e9d6ceef9b0b2546ddf52335785ce41252bc7474ee8ba05bfad277be13ab8" dependencies = [ "async-trait", "futures-channel", "futures-executor", "futures-util", "glob", - "once_cell", "opentelemetry", "percent-encoding", "rand", @@ -1801,6 +1801,7 @@ dependencies = [ "thiserror 1.0.69", "tokio", "tokio-stream", + "tracing", ] [[package]] @@ -2851,9 +2852,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 98ab7b0..e5b8230 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -37,10 +37,10 @@ serde_yaml = "0.9.25" chrono = { version = "0.4.39", features = ["serde"] } tracing = "0.1.41" tracing-subscriber = { version = "0.3.19", features = ["json", "env-filter"] } -tracing-opentelemetry = "0.27.0" -opentelemetry = { version = "0.26.0", features = ["trace"] } -opentelemetry-otlp = { version = "0.26.0", optional = true } -opentelemetry_sdk = { version = "0.26.0", features = ["rt-tokio"] } +tracing-opentelemetry = "0.28.0" +opentelemetry = { version = "0.27.1", features = ["trace"] } +opentelemetry-otlp = { version = "0.27.0", optional = true } +opentelemetry_sdk = { version = "0.27.1", features = ["rt-tokio"] } thiserror = "2.0.9" anyhow = "1.0.95" prometheus-client = "0.22.2" diff --git a/src/telemetry.rs b/src/telemetry.rs index 5202712..7972dfa 100644 --- a/src/telemetry.rs +++ b/src/telemetry.rs @@ -2,6 +2,7 @@ use opentelemetry::trace::{TraceId, TracerProvider}; use opentelemetry_sdk::{runtime, trace as sdktrace, trace::Config, Resource}; use tracing_subscriber::{prelude::*, EnvFilter, Registry}; +use opentelemetry_otlp::{SpanExporter, WithExportConfig}; /// Fetch an opentelemetry::trace::TraceId as hex through the full tracing stack pub fn get_trace_id() -> TraceId { @@ -27,14 +28,12 @@ fn resource() -> Resource { fn init_tracer() -> sdktrace::Tracer { use opentelemetry_otlp::WithExportConfig; let endpoint = std::env::var("OPENTELEMETRY_ENDPOINT_URL").expect("Needs an otel collector"); - let exporter = opentelemetry_otlp::new_exporter().tonic().with_endpoint(endpoint); + let exporter = SpanExporter::builder().with_tonic().with_endpoint(endpoint).build().unwrap(); - let provider = opentelemetry_otlp::new_pipeline() - .tracing() - .with_exporter(exporter) - .with_trace_config(Config::default().with_resource(resource())) - .install_batch(runtime::Tokio) - .expect("valid tracer"); + let provider = sdktrace::TracerProvider::builder() + .with_batch_exporter(exporter, runtime::Tokio) + .with_config(Config::default().with_resource(resource())) + .build(); opentelemetry::global::set_tracer_provider(provider.clone()); provider.tracer("tracing-otel-subscriber")