From 7dff11a83a607ed6e24030fb1421b9bd60870eaa Mon Sep 17 00:00:00 2001 From: asonix Date: Sat, 23 Nov 2024 15:01:09 -0600 Subject: [PATCH] Update opentelemetry to 0.27 --- Cargo.lock | 22 ++++++++++++---------- Cargo.toml | 12 ++++++------ src/init_tracing.rs | 25 ++++++++++++------------- 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 290c0d0..a460182 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1984,9 +1984,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[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", @@ -1998,9 +1998,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", @@ -2012,13 +2012,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", @@ -2028,9 +2029,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", @@ -2045,6 +2046,7 @@ dependencies = [ "thiserror 1.0.69", "tokio", "tokio-stream", + "tracing", ] [[package]] @@ -3598,9 +3600,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 0edf207..c8a59bb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,9 +46,9 @@ metrics-exporter-prometheus = { version = "0.16.0", default-features = false, fe mime = "0.3.17" nanorand = { version = "0.7.0", optional = true } object_store = { version = "0.11.0", features = ["aws"] } -opentelemetry_sdk = { version = "0.26.0", features = ["rt-tokio"] } -opentelemetry = "0.26.0" -opentelemetry-otlp = "0.26.0" +opentelemetry_sdk = { version = "0.27.0", features = ["rt-tokio"] } +opentelemetry = "0.27.0" +opentelemetry-otlp = { version = "0.27.0", features = ["grpc-tonic"] } pin-project-lite = "0.2.14" refinery = { version = "0.8.14", features = ["tokio-postgres", "postgres"] } reqwest = { version = "0.12.5", default-features = false, features = ["json", "rustls-tls-no-provider", "stream"] } @@ -83,7 +83,7 @@ toml = "0.8.14" tracing = "0.1.40" tracing-error = "0.2.0" tracing-log = "0.2.0" -tracing-opentelemetry = "0.27.0" +tracing-opentelemetry = "0.28.0" tracing-subscriber = { version = "0.3.18", features = [ "ansi", "env-filter", @@ -98,6 +98,6 @@ uuid = { version = "1.10.0", features = ["serde", "std", "v4", "v7"] } webpki-roots = "0.26.3" [dependencies.tracing-actix-web] -version = "0.7.14" +version = "0.7.15" default-features = false -features = ["opentelemetry_0_26"] +features = ["opentelemetry_0_27"] diff --git a/src/init_tracing.rs b/src/init_tracing.rs index bcc3098..07eb2ab 100644 --- a/src/init_tracing.rs +++ b/src/init_tracing.rs @@ -76,20 +76,19 @@ where for<'a> S: LookupSpan<'a>, { if let Some(url) = otel.url.as_ref() { - let tracer = opentelemetry_otlp::new_pipeline() - .tracing() - .with_trace_config(opentelemetry_sdk::trace::Config::default().with_resource( - Resource::new(vec![KeyValue::new( - "service.name", - otel.service_name.clone(), - )]), - )) - .with_exporter( - opentelemetry_otlp::new_exporter() - .tonic() - .with_endpoint(url.as_str()), + let exporter = opentelemetry_otlp::SpanExporter::builder() + .with_tonic() + .with_endpoint(url.as_str()) + .build()?; + + let tracer = opentelemetry_sdk::trace::TracerProvider::builder() + .with_config( + opentelemetry_sdk::trace::Config::default().with_resource(Resource::new(vec![ + KeyValue::new("service.name", otel.service_name.clone()), + ])), ) - .install_batch(opentelemetry_sdk::runtime::Tokio)?; + .with_batch_exporter(exporter, opentelemetry_sdk::runtime::Tokio) + .build(); let otel_layer = tracing_opentelemetry::layer() .with_tracer(tracer.tracer("pict-rs-tracer"))