From c3b8637e1908487dee80d007ed4cb2f77002ea27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9e?= Date: Mon, 18 Nov 2024 17:05:16 +0000 Subject: [PATCH] Report a metric to Apollo if fragment reuse is enabled (#6267) Co-authored-by: Bryn Cooke --- apollo-router/src/configuration/metrics.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/apollo-router/src/configuration/metrics.rs b/apollo-router/src/configuration/metrics.rs index 0020b20935..52ec64b384 100644 --- a/apollo-router/src/configuration/metrics.rs +++ b/apollo-router/src/configuration/metrics.rs @@ -49,6 +49,8 @@ impl Metrics { data.populate_user_plugins_instrument(configuration); data.populate_query_planner_experimental_parallelism(configuration); data.populate_deno_or_rust_mode_instruments(configuration); + data.populate_legacy_fragment_usage(configuration); + data.into() } } @@ -494,6 +496,18 @@ impl InstrumentData { ); } + pub(crate) fn populate_legacy_fragment_usage(&mut self, configuration: &Configuration) { + // Fragment generation takes precedence over fragment reuse. Only report when fragment reuse is *actually active*. + if configuration.supergraph.reuse_query_fragments == Some(true) + && !configuration.supergraph.generate_query_fragments + { + self.data.insert( + "apollo.router.config.reuse_query_fragments".to_string(), + (1, HashMap::new()), + ); + } + } + pub(crate) fn populate_query_planner_experimental_parallelism( &mut self, configuration: &Configuration,