metrics service: make metric predicate overridable#16725
Merged
snowp merged 5 commits intoenvoyproxy:mainfrom Jun 2, 2021
Merged
metrics service: make metric predicate overridable#16725snowp merged 5 commits intoenvoyproxy:mainfrom
snowp merged 5 commits intoenvoyproxy:mainfrom
Conversation
added 3 commits
May 30, 2021 17:36
Adds a predicate parameter to the MetricsFlusher class, allowing classes that reuse this code to override the predicate used to determine whether to include stats. Signed-off-by: Snow Pettersen <snowp@lyft.com>
jmarantz
previously approved these changes
May 30, 2021
Contributor
jmarantz
left a comment
There was a problem hiding this comment.
Looks great modulo some test suggestions if you agree.
| TEST_F(MetricsServiceSinkTest, DefaultFlushPredicate) { | ||
| MetricsFlusher flusher(true, true); | ||
|
|
||
| auto used_counter = std::make_shared<NiceMock<Stats::MockCounter>>(); |
Contributor
There was a problem hiding this comment.
nit: suggest a helper function to factor out the 5-line stanzas making the mock counters (used 4x so far).
Contributor
Author
There was a problem hiding this comment.
Added out helper functions to all the metrics types since I was in here, I think this helped the overall readability of the whole file
| } | ||
|
|
||
| TEST_F(MetricsServiceSinkTest, OverridenFlushPredicate) { | ||
| MetricsFlusher flusher(true, true, [](const auto&) { return true; }); |
Contributor
There was a problem hiding this comment.
nit: suggest another test where predicate returns false, which would add another 2 uses of the helper function.
added 2 commits
May 31, 2021 16:27
…e predicate Signed-off-by: Snow Pettersen <snowp@lyft.com>
leyao-daily
pushed a commit
to leyao-daily/envoy
that referenced
this pull request
Sep 30, 2021
Adds a predicate parameter to the MetricsFlusher class, allowing classes that reuse this code to override the predicate used to determine whether to include stats. Signed-off-by: Snow Pettersen <snowp@lyft.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.
Adds the predicate to use to determine whether to include a metric when flushing as a ctor parameter to MetrcsFlusher.
This allows custom sinks that reuse the metrics service components to override the predicate, allowing for modifcations
of which subset of metrics are flushed without having do tamper with the incoming snapshot.
Risk Level: Low, no behavior change
Testing: UTs
Docs Changes: n/a
Release Notes: n/a
Platform Specific Features: n/a