From ae522fb22a2ef220696862c5765c5c3892fcaa9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9e?= Date: Mon, 19 Aug 2024 10:05:48 +0200 Subject: [PATCH] fix: use consistent `query` name in uplink metrics (#5816) --- .changesets/fix_renee_consistent_uplink_type.md | 5 +++++ apollo-router/src/uplink/mod.rs | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changesets/fix_renee_consistent_uplink_type.md diff --git a/.changesets/fix_renee_consistent_uplink_type.md b/.changesets/fix_renee_consistent_uplink_type.md new file mode 100644 index 0000000000..7a6e044edf --- /dev/null +++ b/.changesets/fix_renee_consistent_uplink_type.md @@ -0,0 +1,5 @@ +### Fix inconsistent `type` attribute in `apollo.router.uplink.fetch.duration` metric ([PR #5816](https://github.com/apollographql/router/pull/5816)) + +The router now always reports a short name in the `type` attribute for the `apollo.router.fetch.duration` metric, instead of sometimes using a fully-qualified Rust path and sometimes using a short name. + +By [@goto-bus-stop](https://github.com/goto-bus-stop) in https://github.com/apollographql/router/pull/5816 diff --git a/apollo-router/src/uplink/mod.rs b/apollo-router/src/uplink/mod.rs index d6eb3262c5..6a8974699e 100644 --- a/apollo-router/src/uplink/mod.rs +++ b/apollo-router/src/uplink/mod.rs @@ -414,7 +414,7 @@ where tracing::info!( histogram.apollo_router_uplink_fetch_duration_seconds = now.elapsed().as_secs_f64(), - query = std::any::type_name::(), + query, url = url.to_string(), "kind" = "http_error", error = e.to_string(), @@ -441,7 +441,7 @@ fn query_name() -> &'static str { let mut query = std::any::type_name::(); query = query .strip_suffix("Query") - .expect("Uplink structs mut be named xxxQuery") + .expect("Uplink structs must be named xxxQuery") .get(query.rfind("::").map(|index| index + 2).unwrap_or_default()..) .expect("cannot fail"); query