stats: Add iterate methods for tags.#6764
Conversation
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
|
@eziskind this is intended to provide a higher-performing way for stats sinks to look for a particular stat, rather than building a temp array of string-pairs, per f2f discussion. |
eziskind
left a comment
There was a problem hiding this comment.
Add unit tests - otherwise LGTM, Thanks!
Ah, I see your comment about how the new methods are already tested with unit tests that use "tags". So I guess you don't need to add more |
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
jmarantz
left a comment
There was a problem hiding this comment.
@eziskind actually upon double-checking I don't think there really were good unit-tests for tags(), so I added a few variants in a new test metric_impl_test.cc. It did have indirect coverage but not simple unit-tests, which it deserves.
Signed-off-by: Joshua Marantz <jmarantz@google.com>
|
/retest |
|
🔨 rebuilding |
Signed-off-by: Joshua Marantz <jmarantz@google.com>
Signed-off-by: Joshua Marantz <jmarantz@google.com>
|
Thanks for the re-approve @zuercher :) |
Description: With #6161, the tags are no longer held in memory as a vector, but that structure has to be created when tags() is called. If a caller's goal is to find a tag by name, it's more efficient to capture the tag-name in a StatName in a context, and then iterate over the tags as StatNames looking for it. This provides two variants on an iterate() method to make this easier: the very efficient iterateTagStatNames(), and a slightly more compute-intensive version that iterates over const Tag& objects.
Risk Level: low
Testing: //test/common/stats/... -- note that tags() is already called in various tests, and that depends on all the new method bodies.
Docs Changes: n/a
Release Notes: n/a