vamossagar12 commented on PR #12121:
URL: https://github.com/apache/kafka/pull/12121#issuecomment-1134624584

   > > Do we also have concrete examples of usages of this new API? It would be 
helpful to update one or two metrics which would benefits from this change. 
This would be a good illustration.
   > 
   > Yes, there are quite many places where multiple threads tried to create 
the same metric and has to follow the pattern I described in the JIRA ticket. 
If we just search for the usage of the `metric(metricName)` function, we can 
found a bunch of them, e.g. in `Fetcher`, `ConnectMetrics`, `TaskMetricsGroup`, 
etc.
   > 
   > > Metrics is actually published in our 
[javadoc](https://javadoc.io/doc/org.apache.kafka/kafka-clients/latest/org/apache/kafka/common/metrics/Metrics.html).
 This suggests that changing it would require a KIP, no?
   > 
   > Sounds good. Let's create a tiny KIP to add the function.
   
   Sure. I made following updates in ConnectMetrics:
   
   
https://github.com/apache/kafka/blob/c1467aeeed99a11bae3e69c5d7edeee5bcc3e496/connect/runtime/src/main/java/org/apache/kafka/connect/runtime/ConnectMetrics.java#L320-L332
   
   Note that, IlegalArguementExeception is still possible through metricName() 
method so I didn't remove that from the javadoc.
   
   Also, I created a small KIP for the same: 
https://cwiki.apache.org/confluence/display/KAFKA/KIP-843%3A+Adding+metricOrElseCreate+method+to+Metrics


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to