stats/prometheus: normalize labels for single-label implementations #12057
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Here's a bug we've found in production: when exporting Prometheus metrics, the name of the labels is not consistent when using Single-Label metrics vs Multi-Label metrics. More precisely, the Single-Label metrics API does not perform label normalization (i.e. from CamelCase to snake_case), while the Multi-Label API does perform this normalization.
The normalization into snake_case is sensible, as metric names in Prometheus are idiomatically written in snake case, so the lack of normalization when using single-label metrics feels like an oversight that caused our Prometheus metrics exports to report the wrong metrics.
After this change, the behavior between using a Single-Label metric and a Multi-Label metric with just one label is consistent. This is, however, a breaking change so it should be noted in the release notes.
Related Issue(s)
Fixes #12058
Checklist
Deployment Notes