Return the mutated entry from LabelMap.set and LabelMap.setDelta#748
Closed
krajorama wants to merge 1 commit into
Closed
Return the mutated entry from LabelMap.set and LabelMap.setDelta#748krajorama wants to merge 1 commit into
krajorama wants to merge 1 commit into
Conversation
Both methods previously returned `this` for chaining, but no production caller relied on that — only a handful of tests did. Returning the entry lets callers (Counter, Summary) attach per-entry metadata without a second `entry(labels)` lookup, which doubles the keyFrom+Map.get cost on every increment. Sets up follow-up work for per-series created-timestamps. Signed-off-by: György Krajcsovits <gyorgy.krajcsovits@grafana.com>
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.
I'd like to contribute start timestamp (formerly known as created timestamp) support . For this I need to store the start time in the metric entry, but don't want to look the entry up again after adding to the LabelMap. Would be simpler to have set / setDelta return the entry so I can set the start timestamp. Would be used for counters and histograms. Eventually the start timestamp could be exposed on OpenMetrics 1.0 / 2.0.
Summary
LabelMap.setandLabelMap.setDeltanow return the entry they created or updated, instead ofthis(theLabelMap).thisreturn (the only chained usages were intest/utilTest.js, now de-chained).API-surface note
LabelMapis an internal helper: it's not exported fromindex.js, not documented in the README, andentry()'s JSDoc explicitly says "Used internally by some Metrics. You should probably not call this directly." That said,lib/util.jsships in the published package, so a deep-import consumer could in principle have relied on the chaining return. I judge that risk low and reversible, but flagging it explicitly so you can decide.