8000 Use an explicit match for the labeled metric ping sections · mozilla/glean@912fc80 · GitHub
[go: up one dir, main page]

Skip to content

Commit 912fc80

Browse files
committed
Use an explicit match for the labeled metric ping sections
1 parent 88e30a2 commit 912fc80

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* General
66
* Stop reporting db file sizes during init phase ([#3331](https://github.com/mozilla/glean/pull/3331))
77
* Tiny performance improvement for putting tasks on the dispatcher ([#3318](https://github.com/mozilla/glean/pull/3318))
8+
* Use an explicit match for the labeled metric ping sections ([#3335](https://github.com/mozilla/glean/pull/3335))
89

910
# v66.1.1 (2025-11-06)
1011

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)
0