diff --git a/Cargo.lock b/Cargo.lock index 72317824..fc8c4dd8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -928,7 +928,7 @@ dependencies = [ "hyperlocal", "log", "pin-project-lite", - "rustls 0.23.15", + "rustls 0.23.19", "rustls-native-certs 0.7.3", "rustls-pemfile 2.2.0", "rustls-pki-types", @@ -2014,7 +2014,7 @@ dependencies = [ "http 1.1.0", "hyper 1.5.0", "hyper-util", - "rustls 0.23.15", + "rustls 0.23.19", "rustls-pki-types", "tokio", "tokio-rustls 0.26.0", @@ -2541,55 +2541,56 @@ dependencies = [ [[package]] name = "opentelemetry" -version = "0.24.0" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c365a63eec4f55b7efeceb724f1336f26a9cf3427b70e59e2cd2a5b947fba96" +checksum = "ab70038c28ed37b97d8ed414b6429d343a8bbf44c9f79ec854f3a643029ba6d7" dependencies = [ "futures-core", "futures-sink", "js-sys", - "once_cell", "pin-project-lite", "thiserror", + "tracing", ] [[package]] name = "opentelemetry-prometheus" -version = "0.17.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc4191ce34aa274621861a7a9d68dbcf618d5b6c66b10081631b61fd81fbc015" +checksum = "1b834e966ea5e2d03dfe5f2253f03d22cce21403ee940265070eeee96cee0bcc" dependencies = [ "once_cell", "opentelemetry", "opentelemetry_sdk", "prometheus", "protobuf", + "tracing", ] [[package]] name = "opentelemetry-semantic-conventions" -version = "0.16.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1cefe0543875379e47eb5f1e68ff83f45cc41366a92dfd0d073d513bf68e9a05" +checksum = "bc1b6902ff63b32ef6c489e8048c5e253e2e4a803ea3ea7e783914536eb15c52" [[package]] name = "opentelemetry_sdk" -version = "0.24.1" +version = "0.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692eac490ec80f24a17828d49b40b60f5aeaccdfe6a503f939713afd22bc28df" +checksum = "231e9d6ceef9b0b2546ddf52335785ce41252bc7474ee8ba05bfad277be13ab8" dependencies = [ "async-trait", "futures-channel", "futures-executor", "futures-util", "glob", - "once_cell", "opentelemetry", "percent-encoding", "rand", "serde", "serde_json", "thiserror", + "tracing", ] [[package]] @@ -2877,7 +2878,7 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash", - "rustls 0.23.15", + "rustls 0.23.19", "socket2", "thiserror", "tokio", @@ -2894,7 +2895,7 @@ dependencies = [ "rand", "ring", "rustc-hash", - "rustls 0.23.15", + "rustls 0.23.19", "slab", "thiserror", "tinyvec", @@ -2955,9 +2956,9 @@ dependencies = [ [[package]] name = "redis" -version = "0.27.5" +version = "0.27.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81cccf17a692ce51b86564334614d72dcae1def0fd5ecebc9f02956da74352b5" +checksum = "09d8f99a4090c89cc489a94833c901ead69bfbf3877b4867d5482e321ee875bc" dependencies = [ "arc-swap", "async-trait", @@ -2965,12 +2966,13 @@ dependencies = [ "combine", "crc16", "futures-util", + "itertools 0.13.0", "itoa", "num-bigint", "percent-encoding", "pin-project-lite", "rand", - "rustls 0.23.15", + "rustls 0.23.19", "rustls-native-certs 0.7.3", "rustls-pemfile 2.2.0", "rustls-pki-types", @@ -3053,9 +3055,9 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "reqwest" -version = "0.12.8" +version = "0.12.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f713147fbe92361e52392c73b8c9e48c04c6625bce969ef54dc901e58e042a7b" +checksum = "a77c62af46e79de0a562e1a9849205ffcb7fc1238876e9bd743357570e04046f" dependencies = [ "base64 0.22.1", "bytes", @@ -3079,7 +3081,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "quinn", - "rustls 0.23.15", + "rustls 0.23.19", "rustls-pemfile 2.2.0", "rustls-pki-types", "serde", @@ -3207,9 +3209,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.15" +version = "0.23.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fbb44d7acc4e873d613422379f69f237a1b141928c02f6bc6ccfddddc2d7993" +checksum = "934b404430bb06b3fae2cba809eb45a1ab1aecd64491213d7c3301b88393f8d1" dependencies = [ "log", "once_cell", @@ -3502,9 +3504,9 @@ dependencies = [ [[package]] name = "shadow-rs" -version = "0.35.1" +version = "0.36.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2311e39772c00391875f40e34d43efef247b23930143a70ca5fbec9505937420" +checksum = "58cfcd0643497a9f780502063aecbcc4a3212cbe4948fd25ee8fd179c2cf9a18" dependencies = [ "const_format", "git2", @@ -3857,9 +3859,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.41.1" +version = "1.42.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33" +checksum = "5cec9b21b0450273377fc97bd4c33a8acffc8c996c987a7c5b319a0083707551" dependencies = [ "backtrace", "bytes", @@ -3911,7 +3913,7 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ - "rustls 0.23.15", + "rustls 0.23.19", "rustls-pki-types", "tokio", ] @@ -4197,7 +4199,7 @@ dependencies = [ "rand", "redis", "reqwest", - "rustls 0.23.15", + "rustls 0.23.19", "rustls-pemfile 2.2.0", "rustls-pki-types", "semver", diff --git a/server/Cargo.toml b/server/Cargo.toml index 8b3356ee..24ae6573 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -47,10 +47,10 @@ iter_tools = "0.24.0" itertools = "0.13.0" lazy_static = "1.4.0" num_cpus = "1.16.0" -opentelemetry = { version = "0.24.0", features = ["trace", "metrics"] } -opentelemetry-prometheus = "0.17.0" -opentelemetry-semantic-conventions = "0.16.0" -opentelemetry_sdk = { version = "0.24.0", features = [ +opentelemetry = { version = "0.27.0", features = ["trace", "metrics"] } +opentelemetry-prometheus = "0.27.0" +opentelemetry-semantic-conventions = "0.27.0" +opentelemetry_sdk = { version = "0.27.0", features = [ "metrics", "serde", "serde_json", @@ -60,17 +60,17 @@ prometheus = { version = "0.13.4", features = ["process"] } prometheus-reqwest-remote-write = { version = "0.2.1" } prometheus-static-metric = "0.5.1" rand = "0.8.5" -redis = { version = "0.27.5", features = [ +redis = { version = "0.27.6", features = [ "tokio-comp", "tokio-rustls-comp", "cluster", ] } -reqwest = { version = "0.12.8", default-features = false, features = [ +reqwest = { version = "0.12.9", default-features = false, features = [ "json", "rustls-tls", "native-tls", ] } -rustls = { version = "0.23.15", default-features = false, features = [ +rustls = { version = "0.23.18", default-features = false, features = [ "logging", "ring", "std", @@ -81,8 +81,8 @@ semver = "1.0.23" serde = { version = "1.0.213", features = ["derive"] } serde_json = "1.0.132" serde_qs = { version = "0.13.0", features = ["actix4", "tracing"] } -shadow-rs = { version = "0.35.0" } -tokio = { version = "1.41.0", features = [ +shadow-rs = { version = "0.36.0" } +tokio = { version = "1.42.0", features = [ "macros", "rt-multi-thread", "tracing", @@ -112,4 +112,4 @@ testcontainers-modules = { version = "0.11.3", features = [ tracing-test = "0.2.5" [build-dependencies] -shadow-rs = "0.35.0" +shadow-rs = "0.36.0" diff --git a/server/src/metrics/actix_web_metrics.rs b/server/src/metrics/actix_web_metrics.rs index a6969f6e..5d11da10 100644 --- a/server/src/metrics/actix_web_metrics.rs +++ b/server/src/metrics/actix_web_metrics.rs @@ -4,8 +4,8 @@ use actix_web::dev::ServiceRequest; use actix_web::http::{Method, StatusCode, Version}; use futures::{future, FutureExt}; use futures_core::future::LocalBoxFuture; -use opentelemetry::metrics::{Histogram, Meter, MeterProvider, MetricsError, UpDownCounter}; -use opentelemetry::{global, KeyValue, Value}; +use opentelemetry::metrics::{Histogram, Meter, MeterProvider, UpDownCounter}; +use opentelemetry::{InstrumentationScope, KeyValue, Value}; use opentelemetry_semantic_conventions::trace::{ CLIENT_ADDRESS, HTTP_REQUEST_METHOD, HTTP_RESPONSE_STATUS_CODE, NETWORK_PROTOCOL_NAME, NETWORK_PROTOCOL_VERSION, SERVER_ADDRESS, SERVER_PORT, URL_PATH, URL_SCHEME, @@ -115,25 +115,25 @@ impl Metrics { let http_server_active_requests = meter .i64_up_down_counter(HTTP_SERVER_ACTIVE_REQUESTS) .with_description("HTTP concurrent in-flight requests per route") - .init(); + .build(); let http_server_duration = meter .f64_histogram(HTTP_SERVER_DURATION) .with_description("HTTP inbound request duration per route") .with_unit("ms") - .init(); + .build(); let http_server_request_size = meter .u64_histogram(HTTP_SERVER_REQUEST_SIZE) .with_description("Measures the size of HTTP request messages (compressed).") .with_unit("By") - .init(); + .build(); let http_server_response_size = meter .u64_histogram(HTTP_SERVER_RESPONSE_SIZE) .with_description("Measures the size of HTTP request messages (compressed).") .with_unit("By") - .init(); + .build(); Metrics { http_server_active_requests, @@ -174,9 +174,7 @@ impl RequestMetricsBuilder { /// Build the `RequestMetrics` middleware pub fn build(self) -> RequestMetrics { - let meter = self - .meter - .unwrap_or_else(|| get_versioned_meter(global::meter_provider())); + let meter = self.meter.unwrap(); RequestMetrics { route_formatter: self.route_formatter, @@ -187,11 +185,11 @@ impl RequestMetricsBuilder { /// construct meters for this crate fn get_versioned_meter(meter_provider: impl MeterProvider) -> Meter { - meter_provider.versioned_meter( - "unleash_edge", - Some(env!("CARGO_PKG_VERSION")), - Some(opentelemetry_semantic_conventions::SCHEMA_URL), - None, + meter_provider.meter_with_scope( + InstrumentationScope::builder("unleash_edge") + .with_version(env!("CARGO_PKG_VERSION")) + .with_schema_url(opentelemetry_semantic_conventions::SCHEMA_URL) + .build(), ) } @@ -331,10 +329,7 @@ impl PrometheusMetricsHandler { let encoder = TextEncoder::new(); let metric_families = self.registry.gather(); let mut buf = Vec::new(); - if let Err(err) = encoder.encode(&metric_families[..], &mut buf) { - global::handle_error(MetricsError::Other(err.to_string())); - } - + let _ = encoder.encode(&metric_families[..], &mut buf); String::from_utf8(buf).unwrap_or_default() } }