Update opentelemetry stack

This commit is contained in:
asonix 2024-12-09 19:37:35 -06:00
parent e243bd4600
commit aea64c726a
3 changed files with 29 additions and 27 deletions

25
Cargo.lock generated
View file

@ -2687,23 +2687,23 @@ checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
[[package]] [[package]]
name = "opentelemetry" name = "opentelemetry"
version = "0.24.0" version = "0.27.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c365a63eec4f55b7efeceb724f1336f26a9cf3427b70e59e2cd2a5b947fba96" checksum = "ab70038c28ed37b97d8ed414b6429d343a8bbf44c9f79ec854f3a643029ba6d7"
dependencies = [ dependencies = [
"futures-core", "futures-core",
"futures-sink", "futures-sink",
"js-sys", "js-sys",
"once_cell",
"pin-project-lite", "pin-project-lite",
"thiserror 1.0.69", "thiserror 1.0.69",
"tracing",
] ]
[[package]] [[package]]
name = "opentelemetry-otlp" name = "opentelemetry-otlp"
version = "0.17.0" version = "0.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6b925a602ffb916fb7421276b86756027b37ee708f9dce2dbdcc51739f07e727" checksum = "91cf61a1868dacc576bf2b2a1c3e9ab150af7272909e80085c3173384fe11f76"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"futures-core", "futures-core",
@ -2715,13 +2715,14 @@ dependencies = [
"thiserror 1.0.69", "thiserror 1.0.69",
"tokio", "tokio",
"tonic", "tonic",
"tracing",
] ]
[[package]] [[package]]
name = "opentelemetry-proto" name = "opentelemetry-proto"
version = "0.7.0" version = "0.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30ee9f20bff9c984511a02f082dc8ede839e4a9bf15cc2487c8d6fea5ad850d9" checksum = "a6e05acbfada5ec79023c85368af14abd0b307c015e9064d249b2a950ef459a6"
dependencies = [ dependencies = [
"opentelemetry", "opentelemetry",
"opentelemetry_sdk", "opentelemetry_sdk",
@ -2731,16 +2732,15 @@ dependencies = [
[[package]] [[package]]
name = "opentelemetry_sdk" name = "opentelemetry_sdk"
version = "0.24.1" version = "0.27.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "692eac490ec80f24a17828d49b40b60f5aeaccdfe6a503f939713afd22bc28df" checksum = "231e9d6ceef9b0b2546ddf52335785ce41252bc7474ee8ba05bfad277be13ab8"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"futures-channel", "futures-channel",
"futures-executor", "futures-executor",
"futures-util", "futures-util",
"glob", "glob",
"once_cell",
"opentelemetry", "opentelemetry",
"percent-encoding", "percent-encoding",
"rand", "rand",
@ -2748,6 +2748,7 @@ dependencies = [
"thiserror 1.0.69", "thiserror 1.0.69",
"tokio", "tokio",
"tokio-stream", "tokio-stream",
"tracing",
] ]
[[package]] [[package]]
@ -4549,9 +4550,9 @@ dependencies = [
[[package]] [[package]]
name = "tracing-opentelemetry" name = "tracing-opentelemetry"
version = "0.25.0" version = "0.28.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9784ed4da7d921bc8df6963f8c80a0e4ce34ba6ba76668acadd3edbd985ff3b" checksum = "97a971f6058498b5c0f1affa23e7ea202057a7301dbff68e968b2d578bcbd053"
dependencies = [ dependencies = [
"js-sys", "js-sys",
"once_cell", "once_cell",

View file

@ -47,9 +47,9 @@ metrics-exporter-prometheus = { version = "0.15.0", default-features = false, fe
metrics-util = "0.17.0" metrics-util = "0.17.0"
mime = "0.3.16" mime = "0.3.16"
minify-html = "0.15.0" minify-html = "0.15.0"
opentelemetry = "0.24" opentelemetry = "0.27.1"
opentelemetry_sdk = { version = "0.24", features = ["rt-tokio"] } opentelemetry_sdk = { version = "0.27", features = ["rt-tokio"] }
opentelemetry-otlp = "0.17" opentelemetry-otlp = { version = "0.27", features = ["grpc-tonic"] }
pin-project-lite = "0.2.9" pin-project-lite = "0.2.9"
# pinned to metrics-util # pinned to metrics-util
quanta = "0.12.0" quanta = "0.12.0"
@ -77,7 +77,7 @@ time = { version = "0.3.17", features = ["serde"] }
tracing = "0.1" tracing = "0.1"
tracing-error = "0.2" tracing-error = "0.2"
tracing-log = "0.2" tracing-log = "0.2"
tracing-opentelemetry = "0.25" tracing-opentelemetry = "0.28"
tracing-subscriber = { version = "0.3", features = [ tracing-subscriber = { version = "0.3", features = [
"ansi", "ansi",
"env-filter", "env-filter",

View file

@ -83,17 +83,18 @@ fn init_subscriber(
let subscriber = subscriber.with(console_layer); let subscriber = subscriber.with(console_layer);
if let Some(url) = opentelemetry_url { if let Some(url) = opentelemetry_url {
let tracer_provider = opentelemetry_otlp::new_pipeline() let exporter = opentelemetry_otlp::SpanExporter::builder()
.tracing() .with_tonic()
.with_trace_config(opentelemetry_sdk::trace::Config::default().with_resource( .with_endpoint(url.as_str())
Resource::new(vec![KeyValue::new("service.name", software_name)]), .build()?;
))
.with_exporter( let tracer_provider = opentelemetry_sdk::trace::TracerProvider::builder()
opentelemetry_otlp::new_exporter() .with_resource(Resource::new(vec![KeyValue::new(
.tonic() "service.name",
.with_endpoint(url.as_str()), software_name,
) )]))
.install_batch(opentelemetry_sdk::runtime::Tokio)?; .with_batch_exporter(exporter, opentelemetry_sdk::runtime::Tokio)
.build();
let otel_layer = tracing_opentelemetry::layer() let otel_layer = tracing_opentelemetry::layer()
.with_tracer(tracer_provider.tracer(software_name)) .with_tracer(tracer_provider.tracer(software_name))