diff --git a/Cargo.lock b/Cargo.lock index 3bb7101c..2a3b6032 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -171,7 +171,7 @@ dependencies = [ "chrono", "futures", "graceful-shutdown", - "http 1.1.0", + "http", "log", "pin-project-lite", "serde", @@ -319,7 +319,7 @@ dependencies = [ "fnv", "futures-util", "handlebars", - "http 1.1.0", + "http", "indexmap 2.2.6", "mime", "multer", @@ -606,8 +606,8 @@ dependencies = [ "axum-core", "bytes", "futures-util", - "http 1.1.0", - "http-body 1.0.0", + "http", + "http-body", "http-body-util", "hyper", "hyper-util", @@ -639,8 +639,8 @@ dependencies = [ "async-trait", "bytes", "futures-util", - "http 1.1.0", - "http-body 1.0.0", + "http", + "http-body", "http-body-util", "mime", "pin-project-lite", @@ -663,8 +663,8 @@ dependencies = [ "cookie", "futures-util", "headers", - "http 1.1.0", - "http-body 1.0.0", + "http", + "http-body", "http-body-util", "mime", "pin-project-lite", @@ -862,9 +862,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" +checksum = "a12916984aab3fa6e39d655a33e09c0071eb36d6ab3aea5c2d78551f1df6d952" dependencies = [ "serde", ] @@ -2171,7 +2171,7 @@ dependencies = [ "fnv", "futures-core", "futures-sink", - "http 1.1.0", + "http", "indexmap 2.2.6", "slab", "tokio", @@ -2237,7 +2237,7 @@ dependencies = [ "base64 0.21.7", "bytes", "headers-core", - "http 1.1.0", + "http", "httpdate", "mime", "sha1", @@ -2249,7 +2249,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "54b4a22553d4242c49fddb9ba998a99962b5cc6f22cb5a3482bec22522403ce4" dependencies = [ - "http 1.1.0", + "http", ] [[package]] @@ -2323,17 +2323,6 @@ dependencies = [ "windows", ] -[[package]] -name = "http" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" -dependencies = [ - "bytes", - "fnv", - "itoa", -] - [[package]] name = "http" version = "1.1.0" @@ -2345,17 +2334,6 @@ dependencies = [ "itoa", ] -[[package]] -name = "http-body" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" -dependencies = [ - "bytes", - "http 0.2.12", - "pin-project-lite", -] - [[package]] name = "http-body" version = "1.0.0" @@ -2363,7 +2341,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1cac85db508abc24a2e48553ba12a996e87244a0395ce011e62b37158745d643" dependencies = [ "bytes", - "http 1.1.0", + "http", ] [[package]] @@ -2374,8 +2352,8 @@ checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" dependencies = [ "bytes", "futures-util", - "http 1.1.0", - "http-body 1.0.0", + "http", + "http-body", "pin-project-lite", ] @@ -2407,8 +2385,8 @@ dependencies = [ "futures-channel", "futures-util", "h2", - "http 1.1.0", - "http-body 1.0.0", + "http", + "http-body", "httparse", "httpdate", "itoa", @@ -2425,7 +2403,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155" dependencies = [ "futures-util", - "http 1.1.0", + "http", "hyper", "hyper-util", "rustls 0.23.12", @@ -2445,8 +2423,8 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "http 1.1.0", - "http-body 1.0.0", + "http", + "http-body", "hyper", "pin-project-lite", "socket2 0.5.7", @@ -3142,8 +3120,8 @@ dependencies = [ "data-encoding", "futures-util", "headers", - "http 1.1.0", - "http-body 1.0.0", + "http", + "http-body", "http-body-util", "hyper-util", "icu_locid", @@ -3183,8 +3161,8 @@ dependencies = [ "dialoguer", "dotenvy", "figment", - "http 1.1.0", - "http-body 1.0.0", + "http", + "http-body", "http-body-util", "httpdate", "hyper", @@ -3375,16 +3353,14 @@ dependencies = [ "bytes", "futures-util", "headers", - "http 0.2.12", - "http 1.1.0", - "http-body 1.0.0", + "http", + "http-body", "http-body-util", "hyper", "hyper-rustls", "hyper-util", "mas-tower", "opentelemetry", - "opentelemetry-http", "opentelemetry-semantic-conventions", "pin-project-lite", "rustls 0.23.12", @@ -3530,7 +3506,7 @@ dependencies = [ "bytes", "event-listener 5.3.1", "futures-util", - "http-body 1.0.0", + "http-body", "hyper", "hyper-util", "libc", @@ -3553,7 +3529,7 @@ version = "0.9.0" dependencies = [ "anyhow", "async-trait", - "http 1.1.0", + "http", "serde", "tokio", "url", @@ -3565,7 +3541,7 @@ version = "0.9.0" dependencies = [ "anyhow", "async-trait", - "http 1.1.0", + "http", "mas-axum-utils", "mas-http", "mas-matrix", @@ -3589,7 +3565,7 @@ dependencies = [ "form_urlencoded", "futures-util", "headers", - "http 1.1.0", + "http", "http-body-util", "language-tags", "mas-http", @@ -3743,7 +3719,7 @@ dependencies = [ "arc-swap", "camino", "chrono", - "http 1.1.0", + "http", "mas-data-model", "mas-i18n", "mas-router", @@ -3767,7 +3743,7 @@ dependencies = [ name = "mas-tower" version = "0.9.0" dependencies = [ - "http 1.1.0", + "http", "opentelemetry", "opentelemetry-http", "opentelemetry-semantic-conventions", @@ -3903,7 +3879,7 @@ dependencies = [ "bytes", "encoding_rs", "futures-util", - "http 1.1.0", + "http", "httparse", "memchr", "mime", @@ -4011,7 +3987,7 @@ dependencies = [ "assert_matches", "chrono", "data-encoding", - "http 1.1.0", + "http", "language-tags", "mas-iana", "mas-jose", @@ -4090,9 +4066,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "opentelemetry" -version = "0.23.0" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b69a91d4893e713e06f724597ad630f1fa76057a5e1026c0ca67054a9032a76" +checksum = "4c365a63eec4f55b7efeceb724f1336f26a9cf3427b70e59e2cd2a5b947fba96" dependencies = [ "futures-core", "futures-sink", @@ -4104,34 +4080,38 @@ dependencies = [ [[package]] name = "opentelemetry-http" -version = "0.12.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0ba633e55c5ea6f431875ba55e71664f2fa5d3a90bd34ec9302eecc41c865dd" +checksum = "ad31e9de44ee3538fb9d64fe3376c1362f406162434609e79aea2a41a0af78ab" dependencies = [ "async-trait", "bytes", - "http 0.2.12", + "http", + "http-body-util", + "hyper", + "hyper-util", "opentelemetry", + "tokio", ] [[package]] name = "opentelemetry-jaeger-propagator" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c190755e0aeec909343896f94670446ac686dd1eaf5e2beb4149a7148cfe1d6c" +checksum = "fc0a68a13b92fc708d875ad659b08b35d08b8ef2403e01944b39ca21e5b08b17" dependencies = [ "opentelemetry", ] [[package]] name = "opentelemetry-otlp" -version = "0.16.0" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a94c69209c05319cdf7460c6d4c055ed102be242a0a6245835d7bc42c6ec7f54" +checksum = "6b925a602ffb916fb7421276b86756027b37ee708f9dce2dbdcc51739f07e727" dependencies = [ "async-trait", "futures-core", - "http 0.2.12", + "http", "opentelemetry", "opentelemetry-http", "opentelemetry-proto", @@ -4142,9 +4122,9 @@ dependencies = [ [[package]] name = "opentelemetry-prometheus" -version = "0.16.0" +version = "0.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e1a24eafe47b693cb938f8505f240dc26c71db60df9aca376b4f857e9653ec7" +checksum = "cc4191ce34aa274621861a7a9d68dbcf618d5b6c66b10081631b61fd81fbc015" dependencies = [ "once_cell", "opentelemetry", @@ -4155,9 +4135,9 @@ dependencies = [ [[package]] name = "opentelemetry-proto" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "984806e6cf27f2b49282e2a05e288f30594f3dbc74eb7a6e99422bc48ed78162" +checksum = "30ee9f20bff9c984511a02f082dc8ede839e4a9bf15cc2487c8d6fea5ad850d9" dependencies = [ "opentelemetry", "opentelemetry_sdk", @@ -4167,9 +4147,9 @@ dependencies = [ [[package]] name = "opentelemetry-resource-detectors" -version = "0.2.0" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5cd98b7277913e22e95b6fd3a5f7413438005471a6e33e8a4ae7b9a20be36ad" +checksum = "00a7e965924ad5234917f135243605ef6f2ae3f4da8d3363065d679b2c150f2a" dependencies = [ "opentelemetry", "opentelemetry-semantic-conventions", @@ -4178,15 +4158,15 @@ dependencies = [ [[package]] name = "opentelemetry-semantic-conventions" -version = "0.15.0" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1869fb4bb9b35c5ba8a1e40c9b128a7b4c010d07091e864a29da19e4fe2ca4d7" +checksum = "1cefe0543875379e47eb5f1e68ff83f45cc41366a92dfd0d073d513bf68e9a05" [[package]] name = "opentelemetry-stdout" -version = "0.4.0" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6d080bf06af02b738feb2e6830cf72c30b76ca18b40f555cdf1b53e7b491bfe" +checksum = "d408d4345b8be6129a77c46c3bfc75f0d3476f3091909c7dd99c1f3d78582287" dependencies = [ "async-trait", "chrono", @@ -4201,19 +4181,17 @@ dependencies = [ [[package]] name = "opentelemetry_sdk" -version = "0.23.0" +version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae312d58eaa90a82d2e627fd86e075cf5230b3f11794e2ed74199ebbe572d4fd" +checksum = "692eac490ec80f24a17828d49b40b60f5aeaccdfe6a503f939713afd22bc28df" dependencies = [ "async-trait", "futures-channel", "futures-executor", "futures-util", "glob", - "lazy_static", "once_cell", "opentelemetry", - "ordered-float", "percent-encoding", "rand", "serde_json", @@ -4707,9 +4685,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.12.6" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" +checksum = "e13db3d3fde688c61e2446b4d843bc27a7e8af269a69440c0308021dc92333cc" dependencies = [ "bytes", "prost-derive", @@ -4717,12 +4695,12 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.12.6" +version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" +checksum = "18bec9b0adc4eba778b33684b7ba3e7137789434769ee3ce3930463ef904cfca" dependencies = [ "anyhow", - "itertools 0.12.1", + "itertools 0.13.0", "proc-macro2", "quote", "syn 2.0.68", @@ -4974,8 +4952,8 @@ dependencies = [ "bytes", "futures-core", "futures-util", - "http 1.1.0", - "http-body 1.0.0", + "http", + "http-body", "http-body-util", "hyper", "hyper-rustls", @@ -5485,7 +5463,7 @@ version = "0.34.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c90802b38c899a2c9e557dff25ad186362eddf755d5f5244001b172dd03bead" dependencies = [ - "http 1.1.0", + "http", "pin-project", "sentry-core", "tower-layer", @@ -6336,19 +6314,19 @@ dependencies = [ [[package]] name = "tonic" -version = "0.11.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "76c4eb7a4e9ef9d4763600161f12f5070b92a578e1b634db88a6887844c91a13" +checksum = "38659f4a91aba8598d27821589f5db7dddd94601e7a01b1e485a50e5484c7401" dependencies = [ "async-trait", - "base64 0.21.7", + "base64 0.22.1", "bytes", - "http 0.2.12", - "http-body 0.4.6", + "http", + "http-body", + "http-body-util", "percent-encoding", "pin-project", "prost", - "tokio", "tokio-stream", "tower-layer", "tower-service", @@ -6381,8 +6359,8 @@ dependencies = [ "bitflags 2.6.0", "bytes", "futures-util", - "http 1.1.0", - "http-body 1.0.0", + "http", + "http-body", "http-body-util", "http-range-header", "httpdate", @@ -6481,9 +6459,9 @@ dependencies = [ [[package]] name = "tracing-opentelemetry" -version = "0.24.0" +version = "0.25.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f68803492bf28ab40aeccaecc7021096bd256baf7ca77c3d425d89b35a7be4e4" +checksum = "a9784ed4da7d921bc8df6963f8c80a0e4ce34ba6ba76668acadd3edbd985ff3b" dependencies = [ "js-sys", "once_cell", @@ -7316,7 +7294,7 @@ dependencies = [ "base64 0.21.7", "deadpool", "futures", - "http 1.1.0", + "http", "http-body-util", "hyper", "hyper-util", diff --git a/Cargo.toml b/Cargo.toml index 498bfcdd..083da32d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -79,7 +79,7 @@ features = ["cookie-private", "cookie-key-expansion", "typed-header"] # Bytes [workspace.dependencies.bytes] -version = "1.6.0" +version = "1.6.1" # UTF-8 paths [workspace.dependencies.camino] @@ -241,14 +241,15 @@ version = "0.3.18" # OpenTelemetry [workspace.dependencies.opentelemetry] -version = "0.23.0" +version = "0.24.0" features = ["trace", "metrics"] [workspace.dependencies.opentelemetry-http] -version = "0.12.0" +version = "0.13.0" +features = ["hyper"] [workspace.dependencies.opentelemetry-semantic-conventions] -version = "0.15.0" +version = "0.16.0" [workspace.dependencies.tracing-opentelemetry] -version = "0.24.0" +version = "0.25.0" default-features = false # URL manipulation diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index ae8cb510..a1bac324 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -47,13 +47,13 @@ tracing-subscriber = { workspace = true, features = ["env-filter"] } tracing-opentelemetry.workspace = true opentelemetry.workspace = true opentelemetry-http.workspace = true -opentelemetry-jaeger-propagator = "0.2.0" -opentelemetry-otlp = { version = "0.16.0", default-features = false, features = ["trace", "metrics", "http-proto"] } -opentelemetry-prometheus = "0.16.0" -opentelemetry-resource-detectors = "0.2.0" +opentelemetry-jaeger-propagator = "0.3.0" +opentelemetry-otlp = { version = "0.17.0", default-features = false, features = ["trace", "metrics", "http-proto"] } +opentelemetry-prometheus = "0.17.0" +opentelemetry-resource-detectors = "0.3.0" opentelemetry-semantic-conventions.workspace = true -opentelemetry-stdout = { version = "0.4.0", features = ["trace", "metrics"] } -opentelemetry_sdk = { version = "0.23.0", features = ["trace", "metrics", "rt-tokio"] } +opentelemetry-stdout = { version = "0.5.0", features = ["trace", "metrics"] } +opentelemetry_sdk = { version = "0.24.1", features = ["trace", "metrics", "rt-tokio"] } prometheus = "0.13.4" sentry.workspace = true sentry-tracing.workspace = true diff --git a/crates/cli/src/app_state.rs b/crates/cli/src/app_state.rs index fefe889a..3355559e 100644 --- a/crates/cli/src/app_state.rs +++ b/crates/cli/src/app_state.rs @@ -34,7 +34,7 @@ use mas_storage::{BoxClock, BoxRepository, BoxRng, Repository, SystemClock}; use mas_storage_pg::PgRepository; use mas_templates::Templates; use opentelemetry::{ - metrics::{Histogram, MetricsError, Unit}, + metrics::{Histogram, MetricsError}, KeyValue, }; use rand::SeedableRng; @@ -78,13 +78,13 @@ impl AppState { let usage = meter .i64_observable_up_down_counter("db.connections.usage") .with_description("The number of connections that are currently in `state` described by the state attribute.") - .with_unit(Unit::new("{connection}")) + .with_unit("{connection}") .init(); let max = meter .i64_observable_up_down_counter("db.connections.max") .with_description("The maximum number of open connections allowed.") - .with_unit(Unit::new("{connection}")) + .with_unit("{connection}") .init(); // Observe the number of active and idle connections in the pool @@ -101,7 +101,7 @@ impl AppState { let histogram = meter .u64_histogram("db.client.connections.create_time") .with_description("The time it took to create a new connection.") - .with_unit(Unit::new("ms")) + .with_unit("ms") .init(); self.conn_acquisition_histogram = Some(histogram); diff --git a/crates/cli/src/telemetry.rs b/crates/cli/src/telemetry.rs index c83e7a0c..188c9561 100644 --- a/crates/cli/src/telemetry.rs +++ b/crates/cli/src/telemetry.rs @@ -22,7 +22,6 @@ use mas_config::{ MetricsConfig, MetricsExporterKind, Propagator, TelemetryConfig, TracingConfig, TracingExporterKind, }; -use mas_http::OtelClient; use opentelemetry::{ global, propagation::{TextMapCompositePropagator, TextMapPropagator}, @@ -99,7 +98,7 @@ fn propagator(propagators: &[Propagator]) -> impl TextMapPropagator { fn http_client() -> impl opentelemetry_http::HttpClient + 'static { let client = mas_http::make_untraced_client(); - OtelClient::new(client) + opentelemetry_http::hyper::HyperClient::new_with_timeout(client, Duration::from_secs(30)) } fn stdout_tracer_provider() -> TracerProvider { @@ -109,7 +108,7 @@ fn stdout_tracer_provider() -> TracerProvider { .build() } -fn otlp_tracer(endpoint: Option<&Url>) -> anyhow::Result { +fn otlp_tracer_provider(endpoint: Option<&Url>) -> anyhow::Result { use opentelemetry_otlp::WithExportConfig; let mut exporter = opentelemetry_otlp::new_exporter() @@ -133,10 +132,7 @@ fn tracer(config: &TracingConfig) -> anyhow::Result> { let tracer_provider = match config.exporter { TracingExporterKind::None => return Ok(None), TracingExporterKind::Stdout => stdout_tracer_provider(), - TracingExporterKind::Otlp => { - // The OTLP exporter already creates a tracer and installs it - return Ok(Some(otlp_tracer(config.endpoint.as_ref())?)); - } + TracingExporterKind::Otlp => otlp_tracer_provider(config.endpoint.as_ref())?, }; let tracer = tracer_provider @@ -248,7 +244,7 @@ fn init_meter(config: &MetricsConfig) -> anyhow::Result<()> { } fn trace_config() -> opentelemetry_sdk::trace::Config { - opentelemetry_sdk::trace::config() + opentelemetry_sdk::trace::Config::default() .with_resource(resource()) .with_sampler(Sampler::AlwaysOn) } diff --git a/crates/handlers/src/activity_tracker/worker.rs b/crates/handlers/src/activity_tracker/worker.rs index ef8e1f3e..6c12a528 100644 --- a/crates/handlers/src/activity_tracker/worker.rs +++ b/crates/handlers/src/activity_tracker/worker.rs @@ -65,7 +65,7 @@ impl Worker { let message_counter = meter .u64_counter("mas.activity_tracker.messages") .with_description("The number of messages received by the activity tracker") - .with_unit(opentelemetry::metrics::Unit::new("{messages}")) + .with_unit("{messages}") .init(); // Record stuff on the counter so that the metrics are initialized @@ -85,7 +85,7 @@ impl Worker { let flush_time_histogram = meter .u64_histogram("mas.activity_tracker.flush_time") .with_description("The time it took to flush the activity tracker") - .with_unit(opentelemetry::metrics::Unit::new("ms")) + .with_unit("ms") .init(); Self { diff --git a/crates/http/Cargo.toml b/crates/http/Cargo.toml index bf827c3c..513643e9 100644 --- a/crates/http/Cargo.toml +++ b/crates/http/Cargo.toml @@ -23,7 +23,6 @@ hyper.workspace = true hyper-util.workspace = true hyper-rustls = { workspace = true, optional = true } opentelemetry.workspace = true -opentelemetry-http = { workspace = true, optional = true } opentelemetry-semantic-conventions.workspace = true rustls = { workspace = true, optional = true } rustls-platform-verifier = { workspace = true, optional = true } @@ -37,9 +36,6 @@ tower-http.workspace = true tracing.workspace = true tracing-opentelemetry.workspace = true -# opentelemetry-http still requires http 0.2, and we need to convert types -http02 = { package = "http", version = "0.2.12", optional = true } - mas-tower = { workspace = true, optional = true } [dev-dependencies] @@ -52,8 +48,6 @@ client = [ "dep:rustls", "dep:hyper-rustls", "dep:rustls-platform-verifier", - "dep:http02", - "dep:opentelemetry-http", "tower/limit", "tower-http/timeout", "tower-http/follow-redirect", diff --git a/crates/http/src/client.rs b/crates/http/src/client.rs index 1449778f..f227e35c 100644 --- a/crates/http/src/client.rs +++ b/crates/http/src/client.rs @@ -12,8 +12,6 @@ // See the License for the specific language governing permissions and // limitations under the License. -use bytes::Bytes; -use http_body_util::{BodyExt, Full}; use hyper_rustls::{HttpsConnector, HttpsConnectorBuilder}; pub use hyper_util::client::legacy::Client; use hyper_util::{ @@ -27,7 +25,6 @@ use mas_tower::{ DurationRecorderLayer, DurationRecorderService, FnWrapper, InFlightCounterLayer, InFlightCounterService, TraceLayer, TraceService, }; -use opentelemetry_http::HttpClient; use opentelemetry_semantic_conventions::trace::SERVER_ADDRESS; use tower::Layer; use tracing::Span; @@ -97,76 +94,3 @@ fn make_connector( .enable_http2() .wrap_connector(http) } - -/// A client which can be used by opentelemetry-http to send request through -/// hyper 1.x -/// -/// This is needed until OTEL upgrades to hyper 1.x -/// -#[derive(Debug)] -pub struct OtelClient { - client: UntracedClient>, -} - -impl OtelClient { - /// Create a new [`OtelClient`] from a [`UntracedClient`] - #[must_use] - pub fn new(client: UntracedClient>) -> Self { - Self { client } - } -} - -#[async_trait::async_trait] -impl HttpClient for OtelClient { - async fn send( - &self, - request: opentelemetry_http::Request>, - ) -> Result, opentelemetry_http::HttpError> { - // This is the annoying part: converting the OTEL http0.2 request to a http1 - // request - let (parts, body) = request.into_parts(); - let body = Full::new(Bytes::from(body)); - let mut request = http::Request::new(body); - - *request.uri_mut() = parts.uri.to_string().parse().unwrap(); - *request.method_mut() = match parts.method { - http02::Method::GET => http::Method::GET, - http02::Method::POST => http::Method::POST, - http02::Method::PUT => http::Method::PUT, - http02::Method::DELETE => http::Method::DELETE, - http02::Method::HEAD => http::Method::HEAD, - http02::Method::OPTIONS => http::Method::OPTIONS, - http02::Method::CONNECT => http::Method::CONNECT, - http02::Method::PATCH => http::Method::PATCH, - http02::Method::TRACE => http::Method::TRACE, - _ => return Err(opentelemetry_http::HttpError::from("Unsupported method")), - }; - request - .headers_mut() - .extend(parts.headers.into_iter().map(|(k, v)| { - ( - k.map(|k| http::HeaderName::from_bytes(k.as_ref()).unwrap()), - http::HeaderValue::from_bytes(v.as_ref()).unwrap(), - ) - })); - - // Send the request - let response = self.client.request(request).await?; - - // Convert back the response - let (parts, body) = response.into_parts(); - let body = body.collect().await?.to_bytes(); - let mut response = opentelemetry_http::Response::new(body); - *response.status_mut() = parts.status.as_u16().try_into().unwrap(); - response - .headers_mut() - .extend(parts.headers.into_iter().map(|(k, v)| { - ( - k.map(|k| http02::HeaderName::from_bytes(k.as_ref()).unwrap()), - http02::HeaderValue::from_bytes(v.as_ref()).unwrap(), - ) - })); - - Ok(response) - } -} diff --git a/crates/http/src/layers/client.rs b/crates/http/src/layers/client.rs index 7ca42d7a..eee7946f 100644 --- a/crates/http/src/layers/client.rs +++ b/crates/http/src/layers/client.rs @@ -21,10 +21,13 @@ use mas_tower::{ TraceLayer, TraceService, }; use opentelemetry::KeyValue; -use opentelemetry_semantic_conventions::trace::{ - CLIENT_ADDRESS, CLIENT_PORT, HTTP_REQUEST_BODY_SIZE, HTTP_REQUEST_METHOD, - HTTP_RESPONSE_BODY_SIZE, HTTP_RESPONSE_STATUS_CODE, NETWORK_PROTOCOL_NAME, NETWORK_TRANSPORT, - NETWORK_TYPE, SERVER_ADDRESS, SERVER_PORT, URL_FULL, USER_AGENT_ORIGINAL, +use opentelemetry_semantic_conventions::{ + attribute::{HTTP_REQUEST_BODY_SIZE, HTTP_RESPONSE_BODY_SIZE}, + trace::{ + CLIENT_ADDRESS, CLIENT_PORT, HTTP_REQUEST_METHOD, HTTP_RESPONSE_STATUS_CODE, + NETWORK_PROTOCOL_NAME, NETWORK_TRANSPORT, NETWORK_TYPE, SERVER_ADDRESS, SERVER_PORT, + URL_FULL, USER_AGENT_ORIGINAL, + }, }; use tower::{ limit::{ConcurrencyLimit, GlobalConcurrencyLimitLayer}, diff --git a/crates/http/src/lib.rs b/crates/http/src/lib.rs index 3541ca4f..48b7f801 100644 --- a/crates/http/src/lib.rs +++ b/crates/http/src/lib.rs @@ -26,8 +26,8 @@ mod service; #[cfg(feature = "client")] pub use self::{ client::{ - make_traced_connector, make_untraced_client, Client, OtelClient, TracedClient, - TracedConnector, UntracedClient, UntracedConnector, + make_traced_connector, make_untraced_client, Client, TracedClient, TracedConnector, + UntracedClient, UntracedConnector, }, layers::client::{ClientLayer, ClientService}, }; diff --git a/crates/storage-pg/.sqlx/query-aabefb019c9195b0588882fef562472d6117ff68f8f37d02b7609c94aefdb5d6.json b/crates/storage-pg/.sqlx/query-75a62d170e4c959a14c5698f1da983113e7d1bc565d01e85c158856abb17ddc6.json similarity index 92% rename from crates/storage-pg/.sqlx/query-aabefb019c9195b0588882fef562472d6117ff68f8f37d02b7609c94aefdb5d6.json rename to crates/storage-pg/.sqlx/query-75a62d170e4c959a14c5698f1da983113e7d1bc565d01e85c158856abb17ddc6.json index 8cf4db46..1a1320b7 100644 --- a/crates/storage-pg/.sqlx/query-aabefb019c9195b0588882fef562472d6117ff68f8f37d02b7609c94aefdb5d6.json +++ b/crates/storage-pg/.sqlx/query-75a62d170e4c959a14c5698f1da983113e7d1bc565d01e85c158856abb17ddc6.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT oauth2_device_code_grant_id\n , oauth2_client_id\n , scope\n , device_code\n , user_code\n , created_at\n , expires_at\n , fulfilled_at\n , rejected_at\n , exchanged_at\n , user_session_id\n , oauth2_session_id\n , ip_address as \"ip_address: IpAddr\"\n , user_agent\n FROM \n oauth2_device_code_grant\n\n WHERE device_code = $1\n ", + "query": "\n SELECT oauth2_device_code_grant_id\n , oauth2_client_id\n , scope\n , device_code\n , user_code\n , created_at\n , expires_at\n , fulfilled_at\n , rejected_at\n , exchanged_at\n , user_session_id\n , oauth2_session_id\n , ip_address as \"ip_address: IpAddr\"\n , user_agent\n FROM\n oauth2_device_code_grant\n\n WHERE device_code = $1\n ", "describe": { "columns": [ { @@ -96,5 +96,5 @@ true ] }, - "hash": "aabefb019c9195b0588882fef562472d6117ff68f8f37d02b7609c94aefdb5d6" + "hash": "75a62d170e4c959a14c5698f1da983113e7d1bc565d01e85c158856abb17ddc6" } diff --git a/crates/storage-pg/.sqlx/query-f0977fee9b3919707e9aa20537d836d741acd5b2426218a2f9f9dab4fb8a2ad0.json b/crates/storage-pg/.sqlx/query-89041298e272d15c21e2b7127bd16c5a4f48e2be87dc26e9d0e3a932c9c49dfb.json similarity index 91% rename from crates/storage-pg/.sqlx/query-f0977fee9b3919707e9aa20537d836d741acd5b2426218a2f9f9dab4fb8a2ad0.json rename to crates/storage-pg/.sqlx/query-89041298e272d15c21e2b7127bd16c5a4f48e2be87dc26e9d0e3a932c9c49dfb.json index 59ea3ae1..4b11059e 100644 --- a/crates/storage-pg/.sqlx/query-f0977fee9b3919707e9aa20537d836d741acd5b2426218a2f9f9dab4fb8a2ad0.json +++ b/crates/storage-pg/.sqlx/query-89041298e272d15c21e2b7127bd16c5a4f48e2be87dc26e9d0e3a932c9c49dfb.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT oauth2_device_code_grant_id\n , oauth2_client_id\n , scope\n , device_code\n , user_code\n , created_at\n , expires_at\n , fulfilled_at\n , rejected_at\n , exchanged_at\n , user_session_id\n , oauth2_session_id\n , ip_address as \"ip_address: IpAddr\"\n , user_agent\n FROM \n oauth2_device_code_grant\n\n WHERE oauth2_device_code_grant_id = $1\n ", + "query": "\n SELECT oauth2_device_code_grant_id\n , oauth2_client_id\n , scope\n , device_code\n , user_code\n , created_at\n , expires_at\n , fulfilled_at\n , rejected_at\n , exchanged_at\n , user_session_id\n , oauth2_session_id\n , ip_address as \"ip_address: IpAddr\"\n , user_agent\n FROM\n oauth2_device_code_grant\n\n WHERE oauth2_device_code_grant_id = $1\n ", "describe": { "columns": [ { @@ -96,5 +96,5 @@ true ] }, - "hash": "f0977fee9b3919707e9aa20537d836d741acd5b2426218a2f9f9dab4fb8a2ad0" + "hash": "89041298e272d15c21e2b7127bd16c5a4f48e2be87dc26e9d0e3a932c9c49dfb" } diff --git a/crates/storage-pg/.sqlx/query-9742df9a34fe64e294cae4fc4a18e261c03b2367adeaec8fd554ca6f52c2015e.json b/crates/storage-pg/.sqlx/query-9742df9a34fe64e294cae4fc4a18e261c03b2367adeaec8fd554ca6f52c2015e.json deleted file mode 100644 index d70b3f88..00000000 --- a/crates/storage-pg/.sqlx/query-9742df9a34fe64e294cae4fc4a18e261c03b2367adeaec8fd554ca6f52c2015e.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "db_name": "PostgreSQL", - "query": "\n INSERT INTO \"oauth2_device_code_grant\" \n ( oauth2_device_code_grant_id\n , oauth2_client_id\n , scope\n , device_code\n , user_code\n , created_at\n , expires_at\n , ip_address\n , user_agent\n )\n VALUES\n ($1, $2, $3, $4, $5, $6, $7, $8, $9)\n ", - "describe": { - "columns": [], - "parameters": { - "Left": [ - "Uuid", - "Uuid", - "Text", - "Text", - "Text", - "Timestamptz", - "Timestamptz", - "Inet", - "Text" - ] - }, - "nullable": [] - }, - "hash": "9742df9a34fe64e294cae4fc4a18e261c03b2367adeaec8fd554ca6f52c2015e" -} diff --git a/crates/storage-pg/.sqlx/query-fa5a57505066d03828015f79fdb1079eaea13cf7698073f2d5f74d4c50f7b094.json b/crates/storage-pg/.sqlx/query-bb141d28c0c82244f31d542038c314d05ceb3a7b8f35397c0faef3b36d2d14a7.json similarity index 92% rename from crates/storage-pg/.sqlx/query-fa5a57505066d03828015f79fdb1079eaea13cf7698073f2d5f74d4c50f7b094.json rename to crates/storage-pg/.sqlx/query-bb141d28c0c82244f31d542038c314d05ceb3a7b8f35397c0faef3b36d2d14a7.json index d0ee1ad1..fc966587 100644 --- a/crates/storage-pg/.sqlx/query-fa5a57505066d03828015f79fdb1079eaea13cf7698073f2d5f74d4c50f7b094.json +++ b/crates/storage-pg/.sqlx/query-bb141d28c0c82244f31d542038c314d05ceb3a7b8f35397c0faef3b36d2d14a7.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT oauth2_device_code_grant_id\n , oauth2_client_id\n , scope\n , device_code\n , user_code\n , created_at\n , expires_at\n , fulfilled_at\n , rejected_at\n , exchanged_at\n , user_session_id\n , oauth2_session_id\n , ip_address as \"ip_address: IpAddr\"\n , user_agent\n FROM \n oauth2_device_code_grant\n\n WHERE user_code = $1\n ", + "query": "\n SELECT oauth2_device_code_grant_id\n , oauth2_client_id\n , scope\n , device_code\n , user_code\n , created_at\n , expires_at\n , fulfilled_at\n , rejected_at\n , exchanged_at\n , user_session_id\n , oauth2_session_id\n , ip_address as \"ip_address: IpAddr\"\n , user_agent\n FROM\n oauth2_device_code_grant\n\n WHERE user_code = $1\n ", "describe": { "columns": [ { @@ -96,5 +96,5 @@ true ] }, - "hash": "fa5a57505066d03828015f79fdb1079eaea13cf7698073f2d5f74d4c50f7b094" + "hash": "bb141d28c0c82244f31d542038c314d05ceb3a7b8f35397c0faef3b36d2d14a7" } diff --git a/crates/storage-pg/.sqlx/query-c984ae0496d0bd7520ee3d6761ce6a4f61a6a2001b597e4c63ba4588ec5cf530.json b/crates/storage-pg/.sqlx/query-c984ae0496d0bd7520ee3d6761ce6a4f61a6a2001b597e4c63ba4588ec5cf530.json new file mode 100644 index 00000000..d3b566dd --- /dev/null +++ b/crates/storage-pg/.sqlx/query-c984ae0496d0bd7520ee3d6761ce6a4f61a6a2001b597e4c63ba4588ec5cf530.json @@ -0,0 +1,22 @@ +{ + "db_name": "PostgreSQL", + "query": "\n INSERT INTO \"oauth2_device_code_grant\"\n ( oauth2_device_code_grant_id\n , oauth2_client_id\n , scope\n , device_code\n , user_code\n , created_at\n , expires_at\n , ip_address\n , user_agent\n )\n VALUES\n ($1, $2, $3, $4, $5, $6, $7, $8, $9)\n ", + "describe": { + "columns": [], + "parameters": { + "Left": [ + "Uuid", + "Uuid", + "Text", + "Text", + "Text", + "Timestamptz", + "Timestamptz", + "Inet", + "Text" + ] + }, + "nullable": [] + }, + "hash": "c984ae0496d0bd7520ee3d6761ce6a4f61a6a2001b597e4c63ba4588ec5cf530" +} diff --git a/crates/storage-pg/src/app_session.rs b/crates/storage-pg/src/app_session.rs index 80c8e3aa..908c696c 100644 --- a/crates/storage-pg/src/app_session.rs +++ b/crates/storage-pg/src/app_session.rs @@ -260,7 +260,7 @@ impl<'c> AppSessionRepository for PgAppSessionRepository<'c> { #[tracing::instrument( name = "db.app_session.list", fields( - db.statement, + db.query.text, ), skip_all, err, @@ -408,7 +408,7 @@ impl<'c> AppSessionRepository for PgAppSessionRepository<'c> { #[tracing::instrument( name = "db.app_session.count", fields( - db.statement, + db.query.text, ), skip_all, err, diff --git a/crates/storage-pg/src/compat/access_token.rs b/crates/storage-pg/src/compat/access_token.rs index 4781f9b8..8dc9a9e2 100644 --- a/crates/storage-pg/src/compat/access_token.rs +++ b/crates/storage-pg/src/compat/access_token.rs @@ -65,7 +65,7 @@ impl<'c> CompatAccessTokenRepository for PgCompatAccessTokenRepository<'c> { name = "db.compat_access_token.lookup", skip_all, fields( - db.statement, + db.query.text, compat_session.id = %id, ), err, @@ -99,7 +99,7 @@ impl<'c> CompatAccessTokenRepository for PgCompatAccessTokenRepository<'c> { name = "db.compat_access_token.find_by_token", skip_all, fields( - db.statement, + db.query.text, ), err, )] @@ -135,7 +135,7 @@ impl<'c> CompatAccessTokenRepository for PgCompatAccessTokenRepository<'c> { name = "db.compat_access_token.add", skip_all, fields( - db.statement, + db.query.text, compat_access_token.id, %compat_session.id, user.id = %compat_session.user_id, @@ -185,7 +185,7 @@ impl<'c> CompatAccessTokenRepository for PgCompatAccessTokenRepository<'c> { name = "db.compat_access_token.expire", skip_all, fields( - db.statement, + db.query.text, %compat_access_token.id, compat_session.id = %compat_access_token.session_id, ), diff --git a/crates/storage-pg/src/compat/refresh_token.rs b/crates/storage-pg/src/compat/refresh_token.rs index b5eb414c..6def4aed 100644 --- a/crates/storage-pg/src/compat/refresh_token.rs +++ b/crates/storage-pg/src/compat/refresh_token.rs @@ -74,7 +74,7 @@ impl<'c> CompatRefreshTokenRepository for PgCompatRefreshTokenRepository<'c> { name = "db.compat_refresh_token.lookup", skip_all, fields( - db.statement, + db.query.text, compat_refresh_token.id = %id, ), err, @@ -109,7 +109,7 @@ impl<'c> CompatRefreshTokenRepository for PgCompatRefreshTokenRepository<'c> { name = "db.compat_refresh_token.find_by_token", skip_all, fields( - db.statement, + db.query.text, ), err, )] @@ -146,7 +146,7 @@ impl<'c> CompatRefreshTokenRepository for PgCompatRefreshTokenRepository<'c> { name = "db.compat_refresh_token.add", skip_all, fields( - db.statement, + db.query.text, compat_refresh_token.id, %compat_session.id, user.id = %compat_session.user_id, @@ -196,7 +196,7 @@ impl<'c> CompatRefreshTokenRepository for PgCompatRefreshTokenRepository<'c> { name = "db.compat_refresh_token.consume", skip_all, fields( - db.statement, + db.query.text, %compat_refresh_token.id, compat_session.id = %compat_refresh_token.session_id, ), diff --git a/crates/storage-pg/src/compat/session.rs b/crates/storage-pg/src/compat/session.rs index 20c224e3..62c1cd01 100644 --- a/crates/storage-pg/src/compat/session.rs +++ b/crates/storage-pg/src/compat/session.rs @@ -275,7 +275,7 @@ impl<'c> CompatSessionRepository for PgCompatSessionRepository<'c> { name = "db.compat_session.lookup", skip_all, fields( - db.statement, + db.query.text, compat_session.id = %id, ), err, @@ -312,7 +312,7 @@ impl<'c> CompatSessionRepository for PgCompatSessionRepository<'c> { name = "db.compat_session.add", skip_all, fields( - db.statement, + db.query.text, compat_session.id, %user.id, %user.username, @@ -369,7 +369,7 @@ impl<'c> CompatSessionRepository for PgCompatSessionRepository<'c> { name = "db.compat_session.finish", skip_all, fields( - db.statement, + db.query.text, %compat_session.id, user.id = %compat_session.user_id, compat_session.device.id = compat_session.device.as_str(), @@ -408,7 +408,7 @@ impl<'c> CompatSessionRepository for PgCompatSessionRepository<'c> { #[tracing::instrument( name = "db.compat_session.finish_bulk", skip_all, - fields(db.statement), + fields(db.query.text), err, )] async fn finish_bulk( @@ -435,7 +435,7 @@ impl<'c> CompatSessionRepository for PgCompatSessionRepository<'c> { name = "db.compat_session.list", skip_all, fields( - db.statement, + db.query.text, ), err, )] @@ -536,7 +536,7 @@ impl<'c> CompatSessionRepository for PgCompatSessionRepository<'c> { name = "db.compat_session.count", skip_all, fields( - db.statement, + db.query.text, ), err, )] @@ -561,7 +561,7 @@ impl<'c> CompatSessionRepository for PgCompatSessionRepository<'c> { name = "db.compat_session.record_batch_activity", skip_all, fields( - db.statement, + db.query.text, ), err, )] @@ -608,7 +608,7 @@ impl<'c> CompatSessionRepository for PgCompatSessionRepository<'c> { name = "db.compat_session.record_user_agent", skip_all, fields( - db.statement, + db.query.text, %compat_session.id, ), err, diff --git a/crates/storage-pg/src/compat/sso_login.rs b/crates/storage-pg/src/compat/sso_login.rs index 9615bbea..f89209c8 100644 --- a/crates/storage-pg/src/compat/sso_login.rs +++ b/crates/storage-pg/src/compat/sso_login.rs @@ -143,7 +143,7 @@ impl<'c> CompatSsoLoginRepository for PgCompatSsoLoginRepository<'c> { name = "db.compat_sso_login.lookup", skip_all, fields( - db.statement, + db.query.text, compat_sso_login.id = %id, ), err, @@ -178,7 +178,7 @@ impl<'c> CompatSsoLoginRepository for PgCompatSsoLoginRepository<'c> { name = "db.compat_sso_login.find_for_session", skip_all, fields( - db.statement, + db.query.text, %compat_session.id, ), err, @@ -216,7 +216,7 @@ impl<'c> CompatSsoLoginRepository for PgCompatSsoLoginRepository<'c> { name = "db.compat_sso_login.find_by_token", skip_all, fields( - db.statement, + db.query.text, ), err, )] @@ -253,7 +253,7 @@ impl<'c> CompatSsoLoginRepository for PgCompatSsoLoginRepository<'c> { name = "db.compat_sso_login.add", skip_all, fields( - db.statement, + db.query.text, compat_sso_login.id, compat_sso_login.redirect_uri = %redirect_uri, ), @@ -298,7 +298,7 @@ impl<'c> CompatSsoLoginRepository for PgCompatSsoLoginRepository<'c> { name = "db.compat_sso_login.fulfill", skip_all, fields( - db.statement, + db.query.text, %compat_sso_login.id, %compat_session.id, compat_session.device.id = compat_session.device.as_str(), @@ -343,7 +343,7 @@ impl<'c> CompatSsoLoginRepository for PgCompatSsoLoginRepository<'c> { name = "db.compat_sso_login.exchange", skip_all, fields( - db.statement, + db.query.text, %compat_sso_login.id, ), err, @@ -382,7 +382,7 @@ impl<'c> CompatSsoLoginRepository for PgCompatSsoLoginRepository<'c> { name = "db.compat_sso_login.list", skip_all, fields( - db.statement, + db.query.text, ), err )] @@ -442,7 +442,7 @@ impl<'c> CompatSsoLoginRepository for PgCompatSsoLoginRepository<'c> { name = "db.compat_sso_login.count", skip_all, fields( - db.statement, + db.query.text, ), err )] diff --git a/crates/storage-pg/src/job.rs b/crates/storage-pg/src/job.rs index 3c6b0645..922b562c 100644 --- a/crates/storage-pg/src/job.rs +++ b/crates/storage-pg/src/job.rs @@ -41,7 +41,7 @@ impl<'c> JobRepository for PgJobRepository<'c> { name = "db.job.schedule_submission", skip_all, fields( - db.statement, + db.query.text, job.id, job.name = submission.name(), ), diff --git a/crates/storage-pg/src/lib.rs b/crates/storage-pg/src/lib.rs index 94313d85..584b2c98 100644 --- a/crates/storage-pg/src/lib.rs +++ b/crates/storage-pg/src/lib.rs @@ -86,7 +86,7 @@ //! name = "db.fake_data.lookup", //! skip_all, //! fields( -//! db.statement, +//! db.query.text, //! fake_data.id = %id, //! ), //! err, @@ -115,7 +115,7 @@ //! name = "db.fake_data.add", //! skip_all, //! fields( -//! db.statement, +//! db.query.text, //! fake_data.id, //! ), //! err, @@ -152,8 +152,9 @@ //! A few things to note with the implementation: //! //! - All methods are traced, with an explicit, somewhat consistent name. -//! - The SQL statement is included as attribute, by declaring a `db.statement` -//! attribute on the tracing span, and then calling [`ExecuteExt::traced`]. +//! - The SQL statement is included as attribute, by declaring a +//! `db.query.text` attribute on the tracing span, and then calling +//! [`ExecuteExt::traced`]. //! - The IDs are all [`Ulid`], and generated from the clock and the random //! number generated passed as parameters. The generated IDs are recorded in //! the span. diff --git a/crates/storage-pg/src/oauth2/access_token.rs b/crates/storage-pg/src/oauth2/access_token.rs index f07b8053..8ec97ec0 100644 --- a/crates/storage-pg/src/oauth2/access_token.rs +++ b/crates/storage-pg/src/oauth2/access_token.rs @@ -97,7 +97,7 @@ impl<'c> OAuth2AccessTokenRepository for PgOAuth2AccessTokenRepository<'c> { name = "db.oauth2_access_token.find_by_token", skip_all, fields( - db.statement, + db.query.text, ), err, )] @@ -133,7 +133,7 @@ impl<'c> OAuth2AccessTokenRepository for PgOAuth2AccessTokenRepository<'c> { name = "db.oauth2_access_token.add", skip_all, fields( - db.statement, + db.query.text, %session.id, client.id = %session.client_id, access_token.id, diff --git a/crates/storage-pg/src/oauth2/authorization_grant.rs b/crates/storage-pg/src/oauth2/authorization_grant.rs index ce4d25cf..7681a67a 100644 --- a/crates/storage-pg/src/oauth2/authorization_grant.rs +++ b/crates/storage-pg/src/oauth2/authorization_grant.rs @@ -205,7 +205,7 @@ impl<'c> OAuth2AuthorizationGrantRepository for PgOAuth2AuthorizationGrantReposi name = "db.oauth2_authorization_grant.add", skip_all, fields( - db.statement, + db.query.text, grant.id, grant.scope = %scope, %client.id, @@ -306,7 +306,7 @@ impl<'c> OAuth2AuthorizationGrantRepository for PgOAuth2AuthorizationGrantReposi name = "db.oauth2_authorization_grant.lookup", skip_all, fields( - db.statement, + db.query.text, grant.id = %id, ), err, @@ -354,7 +354,7 @@ impl<'c> OAuth2AuthorizationGrantRepository for PgOAuth2AuthorizationGrantReposi name = "db.oauth2_authorization_grant.find_by_code", skip_all, fields( - db.statement, + db.query.text, ), err, )] @@ -404,7 +404,7 @@ impl<'c> OAuth2AuthorizationGrantRepository for PgOAuth2AuthorizationGrantReposi name = "db.oauth2_authorization_grant.fulfill", skip_all, fields( - db.statement, + db.query.text, %grant.id, client.id = %grant.client_id, %session.id, @@ -447,7 +447,7 @@ impl<'c> OAuth2AuthorizationGrantRepository for PgOAuth2AuthorizationGrantReposi name = "db.oauth2_authorization_grant.exchange", skip_all, fields( - db.statement, + db.query.text, %grant.id, client.id = %grant.client_id, ), @@ -485,7 +485,7 @@ impl<'c> OAuth2AuthorizationGrantRepository for PgOAuth2AuthorizationGrantReposi name = "db.oauth2_authorization_grant.give_consent", skip_all, fields( - db.statement, + db.query.text, %grant.id, client.id = %grant.client_id, ), diff --git a/crates/storage-pg/src/oauth2/client.rs b/crates/storage-pg/src/oauth2/client.rs index e73d3754..034a7ecb 100644 --- a/crates/storage-pg/src/oauth2/client.rs +++ b/crates/storage-pg/src/oauth2/client.rs @@ -31,7 +31,7 @@ use oauth2_types::{ requests::GrantType, scope::{Scope, ScopeToken}, }; -use opentelemetry_semantic_conventions::trace::DB_STATEMENT; +use opentelemetry_semantic_conventions::attribute::DB_QUERY_TEXT; use rand::RngCore; use sqlx::PgConnection; use tracing::{info_span, Instrument}; @@ -288,7 +288,7 @@ impl<'c> OAuth2ClientRepository for PgOAuth2ClientRepository<'c> { name = "db.oauth2_client.lookup", skip_all, fields( - db.statement, + db.query.text, oauth2_client.id = %id, ), err, @@ -337,7 +337,7 @@ impl<'c> OAuth2ClientRepository for PgOAuth2ClientRepository<'c> { name = "db.oauth2_client.load_batch", skip_all, fields( - db.statement, + db.query.text, ), err, )] @@ -393,7 +393,7 @@ impl<'c> OAuth2ClientRepository for PgOAuth2ClientRepository<'c> { name = "db.oauth2_client.add", skip_all, fields( - db.statement, + db.query.text, client.id, client.name = client_name ), @@ -531,7 +531,7 @@ impl<'c> OAuth2ClientRepository for PgOAuth2ClientRepository<'c> { name = "db.oauth2_client.upsert_static", skip_all, fields( - db.statement, + db.query.text, client.id = %client_id, ), err, @@ -640,7 +640,7 @@ impl<'c> OAuth2ClientRepository for PgOAuth2ClientRepository<'c> { name = "db.oauth2_client.all_static", skip_all, fields( - db.statement, + db.query.text, ), err, )] @@ -686,7 +686,7 @@ impl<'c> OAuth2ClientRepository for PgOAuth2ClientRepository<'c> { name = "db.oauth2_client.get_consent_for_user", skip_all, fields( - db.statement, + db.query.text, %user.id, %client.id, ), @@ -727,7 +727,7 @@ impl<'c> OAuth2ClientRepository for PgOAuth2ClientRepository<'c> { name = "db.oauth2_client.give_consent_for_user", skip_all, fields( - db.statement, + db.query.text, %user.id, %client.id, %scope, @@ -777,7 +777,7 @@ impl<'c> OAuth2ClientRepository for PgOAuth2ClientRepository<'c> { name = "db.oauth2_client.delete_by_id", skip_all, fields( - db.statement, + db.query.text, client.id = %id, ), err, @@ -787,7 +787,7 @@ impl<'c> OAuth2ClientRepository for PgOAuth2ClientRepository<'c> { { let span = info_span!( "db.oauth2_client.delete_by_id.authorization_grants", - { DB_STATEMENT } = tracing::field::Empty, + { DB_QUERY_TEXT } = tracing::field::Empty, ); sqlx::query!( @@ -807,7 +807,7 @@ impl<'c> OAuth2ClientRepository for PgOAuth2ClientRepository<'c> { { let span = info_span!( "db.oauth2_client.delete_by_id.consents", - { DB_STATEMENT } = tracing::field::Empty, + { DB_QUERY_TEXT } = tracing::field::Empty, ); sqlx::query!( @@ -827,7 +827,7 @@ impl<'c> OAuth2ClientRepository for PgOAuth2ClientRepository<'c> { { let span = info_span!( "db.oauth2_client.delete_by_id.access_tokens", - { DB_STATEMENT } = tracing::field::Empty, + { DB_QUERY_TEXT } = tracing::field::Empty, ); sqlx::query!( @@ -850,7 +850,7 @@ impl<'c> OAuth2ClientRepository for PgOAuth2ClientRepository<'c> { { let span = info_span!( "db.oauth2_client.delete_by_id.refresh_tokens", - { DB_STATEMENT } = tracing::field::Empty, + { DB_QUERY_TEXT } = tracing::field::Empty, ); sqlx::query!( @@ -873,7 +873,7 @@ impl<'c> OAuth2ClientRepository for PgOAuth2ClientRepository<'c> { { let span = info_span!( "db.oauth2_client.delete_by_id.sessions", - { DB_STATEMENT } = tracing::field::Empty, + { DB_QUERY_TEXT } = tracing::field::Empty, ); sqlx::query!( diff --git a/crates/storage-pg/src/oauth2/device_code_grant.rs b/crates/storage-pg/src/oauth2/device_code_grant.rs index 584dbe00..84b57597 100644 --- a/crates/storage-pg/src/oauth2/device_code_grant.rs +++ b/crates/storage-pg/src/oauth2/device_code_grant.rs @@ -153,7 +153,7 @@ impl<'c> OAuth2DeviceCodeGrantRepository for PgOAuth2DeviceCodeGrantRepository<' name = "db.oauth2_device_code_grant.add", skip_all, fields( - db.statement, + db.query.text, oauth2_device_code.id, oauth2_device_code.scope = %params.scope, oauth2_client.id = %params.client.id, @@ -176,7 +176,7 @@ impl<'c> OAuth2DeviceCodeGrantRepository for PgOAuth2DeviceCodeGrantRepository<' sqlx::query!( r#" - INSERT INTO "oauth2_device_code_grant" + INSERT INTO "oauth2_device_code_grant" ( oauth2_device_code_grant_id , oauth2_client_id , scope @@ -222,7 +222,7 @@ impl<'c> OAuth2DeviceCodeGrantRepository for PgOAuth2DeviceCodeGrantRepository<' name = "db.oauth2_device_code_grant.lookup", skip_all, fields( - db.statement, + db.query.text, oauth2_device_code.id = %id, ), err, @@ -245,7 +245,7 @@ impl<'c> OAuth2DeviceCodeGrantRepository for PgOAuth2DeviceCodeGrantRepository<' , oauth2_session_id , ip_address as "ip_address: IpAddr" , user_agent - FROM + FROM oauth2_device_code_grant WHERE oauth2_device_code_grant_id = $1 @@ -265,7 +265,7 @@ impl<'c> OAuth2DeviceCodeGrantRepository for PgOAuth2DeviceCodeGrantRepository<' name = "db.oauth2_device_code_grant.find_by_user_code", skip_all, fields( - db.statement, + db.query.text, oauth2_device_code.user_code = %user_code, ), err, @@ -291,7 +291,7 @@ impl<'c> OAuth2DeviceCodeGrantRepository for PgOAuth2DeviceCodeGrantRepository<' , oauth2_session_id , ip_address as "ip_address: IpAddr" , user_agent - FROM + FROM oauth2_device_code_grant WHERE user_code = $1 @@ -311,7 +311,7 @@ impl<'c> OAuth2DeviceCodeGrantRepository for PgOAuth2DeviceCodeGrantRepository<' name = "db.oauth2_device_code_grant.find_by_device_code", skip_all, fields( - db.statement, + db.query.text, oauth2_device_code.device_code = %device_code, ), err, @@ -337,7 +337,7 @@ impl<'c> OAuth2DeviceCodeGrantRepository for PgOAuth2DeviceCodeGrantRepository<' , oauth2_session_id , ip_address as "ip_address: IpAddr" , user_agent - FROM + FROM oauth2_device_code_grant WHERE device_code = $1 @@ -357,7 +357,7 @@ impl<'c> OAuth2DeviceCodeGrantRepository for PgOAuth2DeviceCodeGrantRepository<' name = "db.oauth2_device_code_grant.fulfill", skip_all, fields( - db.statement, + db.query.text, oauth2_device_code.id = %device_code_grant.id, oauth2_client.id = %device_code_grant.client_id, browser_session.id = %browser_session.id, @@ -400,7 +400,7 @@ impl<'c> OAuth2DeviceCodeGrantRepository for PgOAuth2DeviceCodeGrantRepository<' name = "db.oauth2_device_code_grant.reject", skip_all, fields( - db.statement, + db.query.text, oauth2_device_code.id = %device_code_grant.id, oauth2_client.id = %device_code_grant.client_id, browser_session.id = %browser_session.id, @@ -443,7 +443,7 @@ impl<'c> OAuth2DeviceCodeGrantRepository for PgOAuth2DeviceCodeGrantRepository<' name = "db.oauth2_device_code_grant.exchange", skip_all, fields( - db.statement, + db.query.text, oauth2_device_code.id = %device_code_grant.id, oauth2_client.id = %device_code_grant.client_id, oauth2_session.id = %session.id, diff --git a/crates/storage-pg/src/oauth2/refresh_token.rs b/crates/storage-pg/src/oauth2/refresh_token.rs index c7132f4f..82d7a0ec 100644 --- a/crates/storage-pg/src/oauth2/refresh_token.rs +++ b/crates/storage-pg/src/oauth2/refresh_token.rs @@ -72,7 +72,7 @@ impl<'c> OAuth2RefreshTokenRepository for PgOAuth2RefreshTokenRepository<'c> { name = "db.oauth2_refresh_token.lookup", skip_all, fields( - db.statement, + db.query.text, refresh_token.id = %id, ), err, @@ -105,7 +105,7 @@ impl<'c> OAuth2RefreshTokenRepository for PgOAuth2RefreshTokenRepository<'c> { name = "db.oauth2_refresh_token.find_by_token", skip_all, fields( - db.statement, + db.query.text, ), err, )] @@ -141,7 +141,7 @@ impl<'c> OAuth2RefreshTokenRepository for PgOAuth2RefreshTokenRepository<'c> { name = "db.oauth2_refresh_token.add", skip_all, fields( - db.statement, + db.query.text, %session.id, client.id = %session.client_id, refresh_token.id, @@ -192,7 +192,7 @@ impl<'c> OAuth2RefreshTokenRepository for PgOAuth2RefreshTokenRepository<'c> { name = "db.oauth2_refresh_token.consume", skip_all, fields( - db.statement, + db.query.text, %refresh_token.id, session.id = %refresh_token.session_id, ), diff --git a/crates/storage-pg/src/oauth2/session.rs b/crates/storage-pg/src/oauth2/session.rs index 07982e22..a79155b8 100644 --- a/crates/storage-pg/src/oauth2/session.rs +++ b/crates/storage-pg/src/oauth2/session.rs @@ -152,7 +152,7 @@ impl<'c> OAuth2SessionRepository for PgOAuth2SessionRepository<'c> { name = "db.oauth2_session.lookup", skip_all, fields( - db.statement, + db.query.text, session.id = %id, ), err, @@ -190,7 +190,7 @@ impl<'c> OAuth2SessionRepository for PgOAuth2SessionRepository<'c> { name = "db.oauth2_session.add", skip_all, fields( - db.statement, + db.query.text, %client.id, session.id, session.scope = %scope, @@ -253,7 +253,7 @@ impl<'c> OAuth2SessionRepository for PgOAuth2SessionRepository<'c> { name = "db.oauth2_session.finish_bulk", skip_all, fields( - db.statement, + db.query.text, ), err, )] @@ -281,7 +281,7 @@ impl<'c> OAuth2SessionRepository for PgOAuth2SessionRepository<'c> { name = "db.oauth2_session.finish", skip_all, fields( - db.statement, + db.query.text, %session.id, %session.scope, client.id = %session.client_id, @@ -318,7 +318,7 @@ impl<'c> OAuth2SessionRepository for PgOAuth2SessionRepository<'c> { name = "db.oauth2_session.list", skip_all, fields( - db.statement, + db.query.text, ), err, )] @@ -390,7 +390,7 @@ impl<'c> OAuth2SessionRepository for PgOAuth2SessionRepository<'c> { name = "db.oauth2_session.count", skip_all, fields( - db.statement, + db.query.text, ), err, )] @@ -415,7 +415,7 @@ impl<'c> OAuth2SessionRepository for PgOAuth2SessionRepository<'c> { name = "db.oauth2_session.record_batch_activity", skip_all, fields( - db.statement, + db.query.text, ), err, )] @@ -462,7 +462,7 @@ impl<'c> OAuth2SessionRepository for PgOAuth2SessionRepository<'c> { name = "db.oauth2_session.record_user_agent", skip_all, fields( - db.statement, + db.query.text, %session.id, %session.scope, client.id = %session.client_id, diff --git a/crates/storage-pg/src/tracing.rs b/crates/storage-pg/src/tracing.rs index 2925f8cc..2244fab9 100644 --- a/crates/storage-pg/src/tracing.rs +++ b/crates/storage-pg/src/tracing.rs @@ -12,19 +12,19 @@ // See the License for the specific language governing permissions and // limitations under the License. -use opentelemetry_semantic_conventions::trace::DB_STATEMENT; +use opentelemetry_semantic_conventions::attribute::DB_QUERY_TEXT; use tracing::Span; /// An extension trait for [`sqlx::Execute`] that records the SQL statement as -/// `db.statement` in a tracing span +/// `db.query.text` in a tracing span pub trait ExecuteExt<'q, DB>: Sized { - /// Records the statement as `db.statement` in the current span + /// Records the statement as `db.query.text` in the current span #[must_use] fn traced(self) -> Self { self.record(&Span::current()) } - /// Records the statement as `db.statement` in the given span + /// Records the statement as `db.query.text` in the given span #[must_use] fn record(self, span: &Span) -> Self; } @@ -35,7 +35,7 @@ where DB: sqlx::Database, { fn record(self, span: &Span) -> Self { - span.record(DB_STATEMENT, self.sql()); + span.record(DB_QUERY_TEXT, self.sql()); self } } diff --git a/crates/storage-pg/src/upstream_oauth2/link.rs b/crates/storage-pg/src/upstream_oauth2/link.rs index 283e574a..a46f5acd 100644 --- a/crates/storage-pg/src/upstream_oauth2/link.rs +++ b/crates/storage-pg/src/upstream_oauth2/link.rs @@ -118,7 +118,7 @@ impl<'c> UpstreamOAuthLinkRepository for PgUpstreamOAuthLinkRepository<'c> { name = "db.upstream_oauth_link.lookup", skip_all, fields( - db.statement, + db.query.text, upstream_oauth_link.id = %id, ), err, @@ -150,7 +150,7 @@ impl<'c> UpstreamOAuthLinkRepository for PgUpstreamOAuthLinkRepository<'c> { name = "db.upstream_oauth_link.find_by_subject", skip_all, fields( - db.statement, + db.query.text, upstream_oauth_link.subject = subject, %upstream_oauth_provider.id, %upstream_oauth_provider.issuer, @@ -191,7 +191,7 @@ impl<'c> UpstreamOAuthLinkRepository for PgUpstreamOAuthLinkRepository<'c> { name = "db.upstream_oauth_link.add", skip_all, fields( - db.statement, + db.query.text, upstream_oauth_link.id, upstream_oauth_link.subject = subject, %upstream_oauth_provider.id, @@ -243,7 +243,7 @@ impl<'c> UpstreamOAuthLinkRepository for PgUpstreamOAuthLinkRepository<'c> { name = "db.upstream_oauth_link.associate_to_user", skip_all, fields( - db.statement, + db.query.text, %upstream_oauth_link.id, %upstream_oauth_link.subject, %user.id, @@ -276,7 +276,7 @@ impl<'c> UpstreamOAuthLinkRepository for PgUpstreamOAuthLinkRepository<'c> { name = "db.upstream_oauth_link.list", skip_all, fields( - db.statement, + db.query.text, ), err, )] @@ -337,7 +337,7 @@ impl<'c> UpstreamOAuthLinkRepository for PgUpstreamOAuthLinkRepository<'c> { name = "db.upstream_oauth_link.count", skip_all, fields( - db.statement, + db.query.text, ), err, )] diff --git a/crates/storage-pg/src/upstream_oauth2/provider.rs b/crates/storage-pg/src/upstream_oauth2/provider.rs index e3e64e31..c28d03a4 100644 --- a/crates/storage-pg/src/upstream_oauth2/provider.rs +++ b/crates/storage-pg/src/upstream_oauth2/provider.rs @@ -21,7 +21,7 @@ use mas_storage::{ }, Clock, Page, Pagination, }; -use opentelemetry_semantic_conventions::trace::DB_STATEMENT; +use opentelemetry_semantic_conventions::attribute::DB_QUERY_TEXT; use rand::RngCore; use sea_query::{enum_def, Expr, PostgresQueryBuilder, Query}; use sea_query_binder::SqlxBinder; @@ -198,7 +198,7 @@ impl<'c> UpstreamOAuthProviderRepository for PgUpstreamOAuthProviderRepository<' name = "db.upstream_oauth_provider.lookup", skip_all, fields( - db.statement, + db.query.text, upstream_oauth_provider.id = %id, ), err, @@ -247,7 +247,7 @@ impl<'c> UpstreamOAuthProviderRepository for PgUpstreamOAuthProviderRepository<' name = "db.upstream_oauth_provider.add", skip_all, fields( - db.statement, + db.query.text, upstream_oauth_provider.id, upstream_oauth_provider.issuer = %params.issuer, upstream_oauth_provider.client_id = %params.client_id, @@ -342,7 +342,7 @@ impl<'c> UpstreamOAuthProviderRepository for PgUpstreamOAuthProviderRepository<' name = "db.upstream_oauth_provider.delete_by_id", skip_all, fields( - db.statement, + db.query.text, upstream_oauth_provider.id = %id, ), err, @@ -354,7 +354,7 @@ impl<'c> UpstreamOAuthProviderRepository for PgUpstreamOAuthProviderRepository<' let span = info_span!( "db.oauth2_client.delete_by_id.authorization_sessions", upstream_oauth_provider.id = %id, - { DB_STATEMENT } = tracing::field::Empty, + { DB_QUERY_TEXT } = tracing::field::Empty, ); sqlx::query!( r#" @@ -375,7 +375,7 @@ impl<'c> UpstreamOAuthProviderRepository for PgUpstreamOAuthProviderRepository<' let span = info_span!( "db.oauth2_client.delete_by_id.links", upstream_oauth_provider.id = %id, - { DB_STATEMENT } = tracing::field::Empty, + { DB_QUERY_TEXT } = tracing::field::Empty, ); sqlx::query!( r#" @@ -408,7 +408,7 @@ impl<'c> UpstreamOAuthProviderRepository for PgUpstreamOAuthProviderRepository<' name = "db.upstream_oauth_provider.add", skip_all, fields( - db.statement, + db.query.text, upstream_oauth_provider.id = %id, upstream_oauth_provider.issuer = %params.issuer, upstream_oauth_provider.client_id = %params.client_id, @@ -523,7 +523,7 @@ impl<'c> UpstreamOAuthProviderRepository for PgUpstreamOAuthProviderRepository<' name = "db.upstream_oauth_provider.disable", skip_all, fields( - db.statement, + db.query.text, %upstream_oauth_provider.id, ), err, @@ -558,7 +558,7 @@ impl<'c> UpstreamOAuthProviderRepository for PgUpstreamOAuthProviderRepository<' name = "db.upstream_oauth_provider.list", skip_all, fields( - db.statement, + db.query.text, ), err, )] @@ -718,7 +718,7 @@ impl<'c> UpstreamOAuthProviderRepository for PgUpstreamOAuthProviderRepository<' name = "db.upstream_oauth_provider.count", skip_all, fields( - db.statement, + db.query.text, ), err, )] @@ -752,7 +752,7 @@ impl<'c> UpstreamOAuthProviderRepository for PgUpstreamOAuthProviderRepository<' name = "db.upstream_oauth_provider.all_enabled", skip_all, fields( - db.statement, + db.query.text, ), err, )] diff --git a/crates/storage-pg/src/upstream_oauth2/session.rs b/crates/storage-pg/src/upstream_oauth2/session.rs index 1f3edcb2..308f33a4 100644 --- a/crates/storage-pg/src/upstream_oauth2/session.rs +++ b/crates/storage-pg/src/upstream_oauth2/session.rs @@ -107,7 +107,7 @@ impl<'c> UpstreamOAuthSessionRepository for PgUpstreamOAuthSessionRepository<'c> name = "db.upstream_oauth_authorization_session.lookup", skip_all, fields( - db.statement, + db.query.text, upstream_oauth_provider.id = %id, ), err, @@ -148,7 +148,7 @@ impl<'c> UpstreamOAuthSessionRepository for PgUpstreamOAuthSessionRepository<'c> name = "db.upstream_oauth_authorization_session.add", skip_all, fields( - db.statement, + db.query.text, %upstream_oauth_provider.id, %upstream_oauth_provider.issuer, %upstream_oauth_provider.client_id, @@ -212,7 +212,7 @@ impl<'c> UpstreamOAuthSessionRepository for PgUpstreamOAuthSessionRepository<'c> name = "db.upstream_oauth_authorization_session.complete_with_link", skip_all, fields( - db.statement, + db.query.text, %upstream_oauth_authorization_session.id, %upstream_oauth_link.id, ), @@ -256,7 +256,7 @@ impl<'c> UpstreamOAuthSessionRepository for PgUpstreamOAuthSessionRepository<'c> name = "db.upstream_oauth_authorization_session.consume", skip_all, fields( - db.statement, + db.query.text, %upstream_oauth_authorization_session.id, ), err, diff --git a/crates/storage-pg/src/user/email.rs b/crates/storage-pg/src/user/email.rs index dea4c867..3b52787d 100644 --- a/crates/storage-pg/src/user/email.rs +++ b/crates/storage-pg/src/user/email.rs @@ -19,7 +19,7 @@ use mas_storage::{ user::{UserEmailFilter, UserEmailRepository}, Clock, Page, Pagination, }; -use opentelemetry_semantic_conventions::trace::DB_STATEMENT; +use opentelemetry_semantic_conventions::attribute::DB_QUERY_TEXT; use rand::RngCore; use sea_query::{enum_def, Expr, PostgresQueryBuilder, Query}; use sea_query_binder::SqlxBinder; @@ -131,7 +131,7 @@ impl<'c> UserEmailRepository for PgUserEmailRepository<'c> { name = "db.user_email.lookup", skip_all, fields( - db.statement, + db.query.text, user_email.id = %id, ), err, @@ -166,7 +166,7 @@ impl<'c> UserEmailRepository for PgUserEmailRepository<'c> { name = "db.user_email.find", skip_all, fields( - db.statement, + db.query.text, %user.id, user_email.email = email, ), @@ -203,7 +203,7 @@ impl<'c> UserEmailRepository for PgUserEmailRepository<'c> { name = "db.user_email.get_primary", skip_all, fields( - db.statement, + db.query.text, %user.id, ), err, @@ -226,7 +226,7 @@ impl<'c> UserEmailRepository for PgUserEmailRepository<'c> { name = "db.user_email.all", skip_all, fields( - db.statement, + db.query.text, %user.id, ), err, @@ -259,7 +259,7 @@ impl<'c> UserEmailRepository for PgUserEmailRepository<'c> { name = "db.user_email.list", skip_all, fields( - db.statement, + db.query.text, ), err, )] @@ -308,7 +308,7 @@ impl<'c> UserEmailRepository for PgUserEmailRepository<'c> { name = "db.user_email.count", skip_all, fields( - db.statement, + db.query.text, ), err, )] @@ -333,7 +333,7 @@ impl<'c> UserEmailRepository for PgUserEmailRepository<'c> { name = "db.user_email.add", skip_all, fields( - db.statement, + db.query.text, %user.id, user_email.id, user_email.email = email, @@ -378,7 +378,7 @@ impl<'c> UserEmailRepository for PgUserEmailRepository<'c> { name = "db.user_email.remove", skip_all, fields( - db.statement, + db.query.text, user.id = %user_email.user_id, %user_email.id, %user_email.email, @@ -388,7 +388,7 @@ impl<'c> UserEmailRepository for PgUserEmailRepository<'c> { async fn remove(&mut self, user_email: UserEmail) -> Result<(), Self::Error> { let span = info_span!( "db.user_email.remove.codes", - { DB_STATEMENT } = tracing::field::Empty + { DB_QUERY_TEXT } = tracing::field::Empty ); sqlx::query!( r#" @@ -461,7 +461,7 @@ impl<'c> UserEmailRepository for PgUserEmailRepository<'c> { name = "db.user_email.add_verification_code", skip_all, fields( - db.statement, + db.query.text, %user_email.id, %user_email.email, user_email_verification.id, @@ -513,7 +513,7 @@ impl<'c> UserEmailRepository for PgUserEmailRepository<'c> { name = "db.user_email.find_verification_code", skip_all, fields( - db.statement, + db.query.text, %user_email.id, user.id = %user_email.user_id, ), @@ -554,7 +554,7 @@ impl<'c> UserEmailRepository for PgUserEmailRepository<'c> { name = "db.user_email.consume_verification_code", skip_all, fields( - db.statement, + db.query.text, %user_email_verification.id, user_email.id = %user_email_verification.user_email_id, ), diff --git a/crates/storage-pg/src/user/mod.rs b/crates/storage-pg/src/user/mod.rs index 211b6306..a97f82d7 100644 --- a/crates/storage-pg/src/user/mod.rs +++ b/crates/storage-pg/src/user/mod.rs @@ -125,7 +125,7 @@ impl<'c> UserRepository for PgUserRepository<'c> { name = "db.user.lookup", skip_all, fields( - db.statement, + db.query.text, user.id = %id, ), err, @@ -158,7 +158,7 @@ impl<'c> UserRepository for PgUserRepository<'c> { name = "db.user.find_by_username", skip_all, fields( - db.statement, + db.query.text, user.username = username, ), err, @@ -191,7 +191,7 @@ impl<'c> UserRepository for PgUserRepository<'c> { name = "db.user.add", skip_all, fields( - db.statement, + db.query.text, user.username = username, user.id, ), @@ -240,7 +240,7 @@ impl<'c> UserRepository for PgUserRepository<'c> { name = "db.user.exists", skip_all, fields( - db.statement, + db.query.text, user.username = username, ), err, @@ -265,7 +265,7 @@ impl<'c> UserRepository for PgUserRepository<'c> { name = "db.user.lock", skip_all, fields( - db.statement, + db.query.text, %user.id, ), err, @@ -300,7 +300,7 @@ impl<'c> UserRepository for PgUserRepository<'c> { name = "db.user.unlock", skip_all, fields( - db.statement, + db.query.text, %user.id, ), err, @@ -333,7 +333,7 @@ impl<'c> UserRepository for PgUserRepository<'c> { name = "db.user.set_can_request_admin", skip_all, fields( - db.statement, + db.query.text, %user.id, user.can_request_admin = can_request_admin, ), @@ -368,7 +368,7 @@ impl<'c> UserRepository for PgUserRepository<'c> { name = "db.user.list", skip_all, fields( - db.statement, + db.query.text, ), err, )] @@ -421,7 +421,7 @@ impl<'c> UserRepository for PgUserRepository<'c> { name = "db.user.count", skip_all, fields( - db.statement, + db.query.text, ), err, )] @@ -446,7 +446,7 @@ impl<'c> UserRepository for PgUserRepository<'c> { name = "db.user.acquire_lock_for_sync", skip_all, fields( - db.statement, + db.query.text, user.id = %user.id, ), err, diff --git a/crates/storage-pg/src/user/password.rs b/crates/storage-pg/src/user/password.rs index 22ff6081..ff6a08dd 100644 --- a/crates/storage-pg/src/user/password.rs +++ b/crates/storage-pg/src/user/password.rs @@ -52,7 +52,7 @@ impl<'c> UserPasswordRepository for PgUserPasswordRepository<'c> { name = "db.user_password.active", skip_all, fields( - db.statement, + db.query.text, %user.id, %user.username, ), @@ -106,7 +106,7 @@ impl<'c> UserPasswordRepository for PgUserPasswordRepository<'c> { name = "db.user_password.add", skip_all, fields( - db.statement, + db.query.text, %user.id, %user.username, user_password.id, diff --git a/crates/storage-pg/src/user/recovery.rs b/crates/storage-pg/src/user/recovery.rs index 2f7829df..0dc08abe 100644 --- a/crates/storage-pg/src/user/recovery.rs +++ b/crates/storage-pg/src/user/recovery.rs @@ -92,7 +92,7 @@ impl<'c> UserRecoveryRepository for PgUserRecoveryRepository<'c> { name = "db.user_recovery.lookup_session", skip_all, fields( - db.statement, + db.query.text, user_recovery_session.id = %id, ), err, @@ -132,7 +132,7 @@ impl<'c> UserRecoveryRepository for PgUserRecoveryRepository<'c> { name = "db.user_recovery.add_session", skip_all, fields( - db.statement, + db.query.text, user_recovery_session.id, user_recovery_session.email = email, user_recovery_session.user_agent = &*user_agent, @@ -191,7 +191,7 @@ impl<'c> UserRecoveryRepository for PgUserRecoveryRepository<'c> { name = "db.user_recovery.find_ticket", skip_all, fields( - db.statement, + db.query.text, user_recovery_ticket.id = ticket, ), err, @@ -230,7 +230,7 @@ impl<'c> UserRecoveryRepository for PgUserRecoveryRepository<'c> { name = "db.user_recovery.add_ticket", skip_all, fields( - db.statement, + db.query.text, user_recovery_ticket.id, user_recovery_ticket.id = ticket, %user_recovery_session.id, @@ -291,7 +291,7 @@ impl<'c> UserRecoveryRepository for PgUserRecoveryRepository<'c> { name = "db.user_recovery.consume_ticket", skip_all, fields( - db.statement, + db.query.text, %user_recovery_ticket.id, user_email.id = %user_recovery_ticket.user_email_id, %user_recovery_session.id, diff --git a/crates/storage-pg/src/user/session.rs b/crates/storage-pg/src/user/session.rs index 95ae1587..c2b71433 100644 --- a/crates/storage-pg/src/user/session.rs +++ b/crates/storage-pg/src/user/session.rs @@ -164,7 +164,7 @@ impl<'c> BrowserSessionRepository for PgBrowserSessionRepository<'c> { name = "db.browser_session.lookup", skip_all, fields( - db.statement, + db.query.text, user_session.id = %id, ), err, @@ -205,7 +205,7 @@ impl<'c> BrowserSessionRepository for PgBrowserSessionRepository<'c> { name = "db.browser_session.add", skip_all, fields( - db.statement, + db.query.text, %user.id, user_session.id, ), @@ -254,7 +254,7 @@ impl<'c> BrowserSessionRepository for PgBrowserSessionRepository<'c> { name = "db.browser_session.finish", skip_all, fields( - db.statement, + db.query.text, %user_session.id, ), err, @@ -289,7 +289,7 @@ impl<'c> BrowserSessionRepository for PgBrowserSessionRepository<'c> { name = "db.browser_session.finish_bulk", skip_all, fields( - db.statement, + db.query.text, ), err, )] @@ -317,7 +317,7 @@ impl<'c> BrowserSessionRepository for PgBrowserSessionRepository<'c> { name = "db.browser_session.list", skip_all, fields( - db.statement, + db.query.text, ), err, )] @@ -404,7 +404,7 @@ impl<'c> BrowserSessionRepository for PgBrowserSessionRepository<'c> { name = "db.browser_session.count", skip_all, fields( - db.statement, + db.query.text, ), err, )] @@ -429,7 +429,7 @@ impl<'c> BrowserSessionRepository for PgBrowserSessionRepository<'c> { name = "db.browser_session.authenticate_with_password", skip_all, fields( - db.statement, + db.query.text, %user_session.id, %user_password.id, user_session_authentication.id, @@ -478,7 +478,7 @@ impl<'c> BrowserSessionRepository for PgBrowserSessionRepository<'c> { name = "db.browser_session.authenticate_with_upstream", skip_all, fields( - db.statement, + db.query.text, %user_session.id, %upstream_oauth_session.id, user_session_authentication.id, @@ -527,7 +527,7 @@ impl<'c> BrowserSessionRepository for PgBrowserSessionRepository<'c> { name = "db.browser_session.get_last_authentication", skip_all, fields( - db.statement, + db.query.text, %user_session.id, ), err, @@ -566,7 +566,7 @@ impl<'c> BrowserSessionRepository for PgBrowserSessionRepository<'c> { name = "db.browser_session.record_batch_activity", skip_all, fields( - db.statement, + db.query.text, ), err, )] diff --git a/crates/storage-pg/src/user/terms.rs b/crates/storage-pg/src/user/terms.rs index abb58e9e..0a5395e5 100644 --- a/crates/storage-pg/src/user/terms.rs +++ b/crates/storage-pg/src/user/terms.rs @@ -44,7 +44,7 @@ impl<'c> UserTermsRepository for PgUserTermsRepository<'c> { name = "db.user_terms.accept_terms", skip_all, fields( - db.statement, + db.query.text, %user.id, user_terms.id, %user_terms.url = terms_url.as_str(), diff --git a/crates/tower/src/metrics/in_flight.rs b/crates/tower/src/metrics/in_flight.rs index 2aa1408c..f7521e00 100644 --- a/crates/tower/src/metrics/in_flight.rs +++ b/crates/tower/src/metrics/in_flight.rs @@ -14,10 +14,7 @@ use std::future::Future; -use opentelemetry::{ - metrics::{Unit, UpDownCounter}, - KeyValue, -}; +use opentelemetry::{metrics::UpDownCounter, KeyValue}; use pin_project_lite::pin_project; use tower::{Layer, Service}; @@ -40,7 +37,7 @@ impl InFlightCounterLayer { pub fn new(name: &'static str) -> Self { let counter = crate::meter() .i64_up_down_counter(name) - .with_unit(Unit::new("{request}")) + .with_unit("{request}") .with_description("The number of in-flight requests") .init(); diff --git a/deny.toml b/deny.toml index 8c7788aa..0dd4293a 100644 --- a/deny.toml +++ b/deny.toml @@ -53,8 +53,8 @@ multiple-versions = "deny" skip = [ { name = "base64", version = "0.21.7" }, # many dependencies depends on this old version - { name = "syn", version = "1.0.109" }, # sea-query, sqlx, schemars depend on the old version - { name = "event-listener", version = "2.5.3" }, # async-channel (wiremock) and sqlx-core depend on the old version + { name = "syn", version = "1.0.109" }, # sea-query, sqlx depend on the old version + { name = "event-listener", version = "2.5.3" }, # sqlx-core depend on the old version { name = "regex-syntax", version = "0.6.29" }, # tracing-subscriber[env-filter] -> matchers depends on the old version { name = "regex-automata", version = "0.1.10" }, # ^ { name = "regex-automata", version = "0.2.0" }, # icu_list depends on this old version @@ -67,20 +67,16 @@ skip = [ { name = "webpki-roots", version = "0.25.3" }, # axum-macros, sqlx-macros and sea-query-attr use an old version { name = "heck", version = "0.4.1" }, - # opentelemetry-http needs this - { name = "http", version = "0.2.12" }, # sea-query-attr uses an old version of darling { name = "darling", version = "0.14.4" }, { name = "darling_core", version = "0.14.4" }, { name = "darling_macro", version = "0.14.4" }, # async-graphql -> toml_edit depends on this old version { name = "winnow", version = "0.5.40" }, - # wasmtime, prost and sqlformat depend on this old version + # wasmtime -> cranelift is depending on this old version { name = "itertools", version = "0.12.1" }, # wasmtime -> cranelift is depending on this old version { name = "gimli", version = "0.28.1" }, - # opentelemetry-otlp -> -proto -> tonic is depending on this old version - { name = "http-body", version = "0.4.6" }, # apalis-core depends on this old version { name = "strum", version = "0.25.0" }, { name = "strum_macros", version = "0.25.0" },