diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a30d2702c..6167236d3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ * General * Stop reporting db file sizes during init phase ([#3331](https://github.com/mozilla/glean/pull/3331)) * Tiny performance improvement for putting tasks on the dispatcher ([#3318](https://github.com/mozilla/glean/pull/3318)) + * Use an explicit match for the labeled metric ping sections ([#3335](https://github.com/mozilla/glean/pull/3335)) # v66.1.1 (2025-11-06) diff --git a/glean-core/src/storage/mod.rs b/glean-core/src/storage/mod.rs index c945f8c9f0..c2526308c6 100644 --- a/glean-core/src/storage/mod.rs +++ b/glean-core/src/storage/mod.rs @@ -32,7 +32,18 @@ fn snapshot_labeled_metrics( metric_id: &str, metric: &Metric, ) { - let ping_section = format!("labeled_{}", metric.ping_section()); + // Explicit match for supported labeled metrics, avoiding the formatting string + let ping_section = match metric.ping_section() { + "boolean" => "labeled_boolean".to_string(), + "counter" => "labeled_counter".to_string(), + "timing_distribution" => "labeled_timing_distribution".to_string(), + "memory_distribution" => "labeled_memory_distribution".to_string(), + "custom_distribution" => "labeled_custom_distribution".to_string(), + "quantity" => "labeled_quantity".to_string(), + // This should never happen, we covered all cases. + // Should we ever extend it this would however at least catch it and do the right thing. + _ => format!("labeled_{}", metric.ping_section()), + }; let map = snapshot.entry(ping_section).or_default(); // Safe unwrap, the function is only called when the id does contain a '/'