You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2022/06/13 18:53:35 UTC

[GitHub] [kafka] guozhangwang opened a new pull request, #12287: KAFKA-13846: Use the new addMetricsIfAbsent API

guozhangwang opened a new pull request, #12287:
URL: https://github.com/apache/kafka/pull/12287

   Use the newly added function to replace the old `addMetric` function that may throw illegal argument exceptions.
   
   Although in some cases concurrency should not be possible they do not necessarily remain always true in the future, so it's better to use the new API just to be less error-prone.
   
   ### Committer Checklist (excluded from commit message)
   - [ ] Verify design and implementation 
   - [ ] Verify test coverage and CI build status
   - [ ] Verify documentation (including upgrade notes)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] guozhangwang merged pull request #12287: KAFKA-13846: Use the new addMetricsIfAbsent API

Posted by GitBox <gi...@apache.org>.
guozhangwang merged PR #12287:
URL: https://github.com/apache/kafka/pull/12287


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] guozhangwang commented on a diff in pull request #12287: KAFKA-13846: Use the new addMetricsIfAbsent API

Posted by GitBox <gi...@apache.org>.
guozhangwang commented on code in PR #12287:
URL: https://github.com/apache/kafka/pull/12287#discussion_r896037230


##########
streams/src/main/java/org/apache/kafka/streams/processor/internals/metrics/StreamsMetricsImpl.java:
##########
@@ -502,9 +502,8 @@ public <T> void addStoreLevelMutableMetric(final String taskId,
             storeLevelTagMap(taskId, metricsScope, storeName)
         );
         if (metrics.metric(metricName) == null) {
-            final MetricConfig metricConfig = new MetricConfig().recordLevel(recordingLevel);
+            metrics.addMetricIfAbsent(metricName, new MetricConfig().recordLevel(recordingLevel), valueProvider);

Review Comment:
   Just take here as an example: here we depend on two threads would not try to create the same store-name and the same task-id but that may not always hold true in the future, so better using the newly introduced API. cc @cadonna .



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] cadonna commented on pull request #12287: KAFKA-13846: Use the new addMetricsIfAbsent API

Posted by GitBox <gi...@apache.org>.
cadonna commented on PR #12287:
URL: https://github.com/apache/kafka/pull/12287#issuecomment-1155052584

   You need to replace 
   ```
   metrics.addMetric(eq(metricName), eqMetricConfig(metricConfig), eq(VALUE_PROVIDER));
   ```
   with
   
   ```
   expect(metrics.addMetricIfAbsent(eq(metricName), eqMetricConfig(metricConfig), eq(VALUE_PROVIDER))).andReturn(null);
   ```
   
   in `StreamsMetricsImplTest#shouldAddNewStoreLevelMutableMetric()`  


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] guozhangwang commented on pull request #12287: KAFKA-13846: Use the new addMetricsIfAbsent API

Posted by GitBox <gi...@apache.org>.
guozhangwang commented on PR #12287:
URL: https://github.com/apache/kafka/pull/12287#issuecomment-1154265926

   cc @vamossagar12 @cadonna 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] cadonna commented on a diff in pull request #12287: KAFKA-13846: Use the new addMetricsIfAbsent API

Posted by GitBox <gi...@apache.org>.
cadonna commented on code in PR #12287:
URL: https://github.com/apache/kafka/pull/12287#discussion_r896682835


##########
streams/src/main/java/org/apache/kafka/streams/processor/internals/metrics/StreamsMetricsImpl.java:
##########
@@ -502,9 +502,8 @@ public <T> void addStoreLevelMutableMetric(final String taskId,
             storeLevelTagMap(taskId, metricsScope, storeName)
         );
         if (metrics.metric(metricName) == null) {
-            final MetricConfig metricConfig = new MetricConfig().recordLevel(recordingLevel);
+            metrics.addMetricIfAbsent(metricName, new MetricConfig().recordLevel(recordingLevel), valueProvider);

Review Comment:
   Agreed!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] cadonna commented on pull request #12287: KAFKA-13846: Use the new addMetricsIfAbsent API

Posted by GitBox <gi...@apache.org>.
cadonna commented on PR #12287:
URL: https://github.com/apache/kafka/pull/12287#issuecomment-1155042727

   @guozhangwang the test failures are related.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [kafka] guozhangwang closed pull request #12287: KAFKA-13846: Use the new addMetricsIfAbsent API

Posted by GitBox <gi...@apache.org>.
guozhangwang closed pull request #12287: KAFKA-13846: Use the new addMetricsIfAbsent API
URL: https://github.com/apache/kafka/pull/12287


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org