diff --git a/Cargo.lock b/Cargo.lock index 5748bc1..11f8e78 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -312,7 +312,7 @@ dependencies = [ "serde_path_to_error", "serde_urlencoded", "sha1", - "sync_wrapper 1.0.1", + "sync_wrapper 1.0.2", "tokio", "tokio-tungstenite", "tower 0.5.1", @@ -336,7 +336,7 @@ dependencies = [ "mime", "pin-project-lite", "rustversion", - "sync_wrapper 1.0.1", + "sync_wrapper 1.0.2", "tower-layer", "tower-service", "tracing", @@ -1648,9 +1648,9 @@ dependencies = [ [[package]] name = "itoa" -version = "1.0.12" +version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a73e9fe3c49d7afb2ace819fa181a287ce54a0983eda4e0eb05c22f82ffe534" +checksum = "540654e97a3f4470a492cd30ff187bc95d89557a903a2bbf112e2fae98104ef2" [[package]] name = "jobserver" @@ -2070,9 +2070,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", @@ -2084,9 +2084,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", @@ -2098,13 +2098,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", @@ -2114,15 +2115,15 @@ dependencies = [ [[package]] name = "opentelemetry-semantic-conventions" -version = "0.26.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db945c1eaea8ac6a9677185357480d215bb6999faa9f691d0c4d4d641eab7a09" +checksum = "bc1b6902ff63b32ef6c489e8048c5e253e2e4a803ea3ea7e783914536eb15c52" [[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", @@ -2137,6 +2138,7 @@ dependencies = [ "thiserror 1.0.69", "tokio", "tokio-stream", + "tracing", ] [[package]] @@ -2335,9 +2337,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.89" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" +checksum = "307e3004becf10f5a6e0d59d20f3cd28231b0e0827a96cd3e0ce6d14bc1e4bb3" dependencies = [ "unicode-ident", ] @@ -2579,7 +2581,7 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", - "sync_wrapper 1.0.1", + "sync_wrapper 1.0.2", "system-configuration", "tokio", "tokio-native-tls", @@ -3211,9 +3213,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" -version = "2.0.87" +version = "2.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" +checksum = "44d46482f1c1c87acd84dea20c1bf5ebff4c757009ed6bf19cfd36fb10e92c4e" dependencies = [ "proc-macro2", "quote", @@ -3228,9 +3230,9 @@ checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" [[package]] name = "sync_wrapper" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" dependencies = [ "futures-core", ] @@ -3610,9 +3612,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 7222d84..61b1289 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -43,16 +43,16 @@ axum = "0.7.7" dotenvy = "0.15.7" metrics = "0.24" metrics-exporter-prometheus = "0.16.0" -opentelemetry = "0.26.0" -opentelemetry-otlp = { version = "0.26.0", features = ["grpc-tonic"] } -opentelemetry-semantic-conventions = "0.26.0" -opentelemetry_sdk = { version = "0.26.0", features = ["rt-tokio"] } +opentelemetry = "0.27.0" +opentelemetry-otlp = { version = "0.27.0", features = ["grpc-tonic"] } +opentelemetry-semantic-conventions = "0.27.0" +opentelemetry_sdk = { version = "0.27.0", features = ["rt-tokio"] } serde = { version = "1.0.210", features = ["derive"] } sqlx = { version = "0.8.2", features = ["runtime-tokio-rustls", "sqlite"] } tokio = { version = "1.40.1", features = ["full"] } tower-http = { version = "0.6.2", features = ["compression-br", "compression-gzip", "fs", "timeout"] } tracing = "0.1.40" -tracing-opentelemetry = "0.27.0" +tracing-opentelemetry = "0.28.0" tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } [dev-dependencies] diff --git a/src/observability/tracing.rs b/src/observability/tracing.rs index 9e4c348..82fee6e 100644 --- a/src/observability/tracing.rs +++ b/src/observability/tracing.rs @@ -1,7 +1,7 @@ use std::env; use opentelemetry::{global, trace::TracerProvider, KeyValue}; -use opentelemetry_otlp::{ExportConfig, Protocol, WithExportConfig}; +use opentelemetry_otlp::{Protocol, WithExportConfig}; use opentelemetry_sdk::{ runtime, trace::{RandomIdGenerator, Sampler, Tracer}, @@ -57,21 +57,20 @@ pub fn create_tracing_subscriber_from_env() { } fn init_tracer(config: OpenTelemetryConfig) -> Tracer { - let tracer_provider = opentelemetry_otlp::new_pipeline() - .tracing() - .with_exporter( - opentelemetry_otlp::new_exporter() - .tonic() - .with_export_config(ExportConfig { - endpoint: format!( - "{}:{}", - config.opentelemetry_agent_host, config.opentelemetry_agent_port - ), - timeout: std::time::Duration::from_secs(3), - protocol: Protocol::Grpc, - }), - ) - .with_trace_config( + let exporter = opentelemetry_otlp::SpanExporter::builder() + .with_tonic() + .with_endpoint(format!( + "{}:{}", + config.opentelemetry_agent_host, config.opentelemetry_agent_port + )) + .with_timeout(std::time::Duration::from_secs(3)) + .with_protocol(Protocol::Grpc) + .build() + .expect("should be using a tokio runtime"); + + let tracer_provider = opentelemetry_sdk::trace::TracerProvider::builder() + .with_batch_exporter(exporter, runtime::Tokio) + .with_config( opentelemetry_sdk::trace::Config::default() .with_sampler(Sampler::AlwaysOn) .with_id_generator(RandomIdGenerator::default()) @@ -80,8 +79,7 @@ fn init_tracer(config: OpenTelemetryConfig) -> Tracer { config.tracing_service_name, )])), ) - .install_batch(runtime::Tokio) - .expect("should be using a tokio runtime"); + .build(); global::set_tracer_provider(tracer_provider.clone()); tracer_provider.tracer("axum-graphql")