Skip to content

Commit 24f3a4f

Browse files
committed
Use an explicit match for the labeled metric ping sections
1 parent 137221b commit 24f3a4f

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
[Full changelog](https://github.com/mozilla/glean/compare/v66.1.1...main)
44

5+
* General
6+
* Use an explicit match for the labeled metric ping sections ([#3335](https://github.com/mozilla/glean/pull/3335))
7+
58
# v66.1.1 (2025-11-06)
69

710
[Full changelog](https://github.com/mozilla/glean/compare/v66.1.0...v66.1.1)

glean-core/src/storage/mod.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,18 @@ fn snapshot_labeled_metrics(
3232
metric_id: &str,
3333
metric: &Metric,
3434
) {
35-
let ping_section = format!("labeled_{}", metric.ping_section());
35+
// Explicit match for supported labeled metrics, avoiding the formatting string
36+
let ping_section = match metric.ping_section() {
37+
"boolean" => "labeled_boolean".to_string(),
38+
"counter" => "labeled_counter".to_string(),
39+
"timing_distribution" => "labeled_timing_distribution".to_string(),
40+
"memory_distribution" => "labeled_memory_distribution".to_string(),
41+
"custom_distribution" => "labeled_custom_distribution".to_string(),
42+
"quantity" => "labeled_quantity".to_string(),
43+
// This should never happen, we covered all cases.
44+
// Should we ever extend it this would however at least catch it and do the right thing.
45+
_ => format!("labeled_{}", metric.ping_section()),
46+
};
3647
let map = snapshot.entry(ping_section).or_default();
3748

3849
// Safe unwrap, the function is only called when the id does contain a '/'

0 commit comments

Comments
 (0)