KAFKA-19398: (De)Register oldest-iterator-open-since-ms metric dynamically#20022
KAFKA-19398: (De)Register oldest-iterator-open-since-ms metric dynamically#20022mjsax merged 3 commits intoapache:trunkfrom
Conversation
…cally The metric for oldest-iterator-open-since-ms might report a null value if there is not open iterator. This PR changes the behavior to dynamically register/deregister the entire metric instead of allowing it to return a null value.
71192dc to
05e6afd
Compare
|
|
||
| public void add(final MeteredIterator iterator) { | ||
| openIterators.add(iterator); | ||
| numOpenIterators.increment(); |
There was a problem hiding this comment.
Seems this has historic reasons -- I just "refactored" existing code.
KIP-989 introduced 4 new metrics which got added by 4 PRs.
numOpenIterators-> KAFKA-15541: Add num-open-iterators metric #15975openIterators-> KAFKA-15541: Add oldest-iterator-open-since-ms metric #16041
(omitting the other two PRs as they are irrelevant)
There was also a follow up PR fro numOpenIterators: #16076
@nicktelford do you see any reason why we need both variables, or can we unify them?
There was a problem hiding this comment.
Guess we can also do this unification only in trunk to get this into 4.1 on time?
There was a problem hiding this comment.
Guess we can also do this unification only in trunk to get this into 4.1 on time?
That works for me
There was a problem hiding this comment.
I'm not certain, but it's possible the LongAdder and Set duplicating the counting functionality is just an oversight. In theory, using the LongAdder would yield improved performance vs. openIterators.size(), however, in practice the total number of open iterators is not likely to be large enough to be a problem, so it seems reasonable to remove numOpenIterators.
There was a problem hiding this comment.
Are you interested to do a PR for this @nicktelford? If not, happy to do one myself.
| storeLevelMetrics.computeIfAbsent(key, ignored -> new LinkedList<>()).push(metricName); | ||
| } | ||
|
|
||
| return metricName; |
There was a problem hiding this comment.
Why does addX return the MetricName obejct?
There was a problem hiding this comment.
We need the MetricName to be able to remove it when the iterator count goes to zero.
| final String storeName, | ||
| final StreamsMetricsImpl streamsMetrics, | ||
| final Gauge<Long> oldestOpenIteratorGauge) { | ||
| return streamsMetrics.addStoreLevelMutableMetric( |
|
|
||
| public void add(final MeteredIterator iterator) { | ||
| openIterators.add(iterator); | ||
| numOpenIterators.increment(); |
There was a problem hiding this comment.
Seems this has historic reasons -- I just "refactored" existing code.
KIP-989 introduced 4 new metrics which got added by 4 PRs.
numOpenIterators-> KAFKA-15541: Add num-open-iterators metric #15975openIterators-> KAFKA-15541: Add oldest-iterator-open-since-ms metric #16041
(omitting the other two PRs as they are irrelevant)
There was also a follow up PR fro numOpenIterators: #16076
@nicktelford do you see any reason why we need both variables, or can we unify them?
| storeLevelMetrics.computeIfAbsent(key, ignored -> new LinkedList<>()).push(metricName); | ||
| } | ||
|
|
||
| return metricName; |
There was a problem hiding this comment.
We need the MetricName to be able to remove it when the iterator count goes to zero.
| final String storeName, | ||
| final StreamsMetricsImpl streamsMetrics, | ||
| final Gauge<Long> oldestOpenIteratorGauge) { | ||
| return streamsMetrics.addStoreLevelMutableMetric( |
| numOpenIterators.increment(); | ||
|
|
||
| if (numOpenIterators.intValue() == 1) { | ||
| metricName = StateStoreMetrics.addOldestOpenIteratorGauge(taskId.toString(), metricsScope, name, streamsMetrics, |
There was a problem hiding this comment.
Answer to your question: we need to remember the MetricName here, to be able to use it to remove the metric if the iterator count goes back to zero.
|
Merged to |
…cally (#20022) The metric for oldest-iterator-open-since-ms might report a null value if there is not open iterator. This PR changes the behavior to dynamically register/deregister the entire metric instead of allowing it to return a null value. Reviewers: Bill Bejeck <bbejeck@apache.org>
…cally (apache#20022) The metric for oldest-iterator-open-since-ms might report a null value if there is not open iterator. This PR changes the behavior to dynamically register/deregister the entire metric instead of allowing it to return a null value. Reviewers: Bill Bejeck <bbejeck@apache.org>
…cally (apache#20022) The metric for oldest-iterator-open-since-ms might report a null value if there is not open iterator. This PR changes the behavior to dynamically register/deregister the entire metric instead of allowing it to return a null value. Reviewers: Bill Bejeck <bbejeck@apache.org>
…c dynamically (apache#20022)" This reverts commit fb054b5.
The metric for oldest-iterator-open-since-ms might report a null value
if there is not open iterator.
This PR changes the behavior to dynamically register/deregister the
entire metric instead of allowing it to return a null value.
Reviewers: Bill Bejeck bbejeck@apache.org