Repository navigation
fix(registry): apply defaults to nullish histogram labels - #859
Open
ethanolchik wants to merge 1 commit into
Open
ethanolchik wants to merge 1 commit into
ethanolchik wants to merge 1 commit into
Conversation
Signed-off-by: Ethan Olchik <[email protected]>
krajorama
reviewed
Sep 29, 2026
krajorama
left a comment
Member
There was a problem hiding this comment.
LGTM, couple of comments on the test
| }); | ||
|
|
||
| it.each([null, undefined])( | ||
| 'uses registry defaults for a shared histogram label with value %p', |
Member
There was a problem hiding this comment.
nit: seems like this should be inside "Registry with default labels" tests?
| histogram.observe({ service: value }, 0.5); | ||
| const before = await histogram.getForPromString(); | ||
| const labels = { ...before.values[0].sharedLabels }; | ||
| expect(await register.metrics()).toContain('service="frontend"'); |
Member
There was a problem hiding this comment.
This seems a bit weak, it only check for contain, so would allow this string to be there twice in a row. Can we make it more explicit , for example match the whole line?
| for (const val of metric.values ?? []) { | ||
| const { metricName = name, labels = {}, sharedLabels } = val; | ||
| const { metricName = name, labels = {} } = val; | ||
| let { sharedLabels } = val; |
Member
There was a problem hiding this comment.
not for this PR: LLM complains that this is making a copy for every bucket in the histogram and suggest making a small cache, but I think it's complicated enough to warrant it's own optimization PR next.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Apply registry default labels when a histogram's shared label value is
nullorundefined. The formatter updates a copy of the shared labels, so the stored metric data is not mutated.Testing
nullandundefinedshared histogram labels.