slfan1989 commented on code in PR #1346:
URL: https://github.com/apache/ratis/pull/1346#discussion_r2795575856
##########
ratis-grpc/src/main/java/org/apache/ratis/grpc/metrics/MessageMetrics.java:
##########
@@ -58,17 +58,9 @@ private static RatisMetricRegistry createRegistry(String
endpointId, String endp
}
private void inc(String metricNamePrefix, Type t) {
- types.get(t)
- .computeIfAbsent(metricNamePrefix, prefix ->
getRegistry().counter(prefix + t.getSuffix()))
- .inc();
- final Map<String, LongCounter> counters = types.get(t);
- LongCounter c = counters.get(metricNamePrefix);
- if (c == null) {
- synchronized (counters) {
- c = counters.computeIfAbsent(metricNamePrefix, prefix ->
getRegistry().counter(prefix + t.getSuffix()));
- }
- }
- c.inc();
+ final LongCounter counter = types.get(t)
+ .computeIfAbsent(metricNamePrefix, prefix ->
getRegistry().counter(prefix + t.getSuffix()));
+ counter.inc();
Review Comment:
Thank you for reviewing the code! I’ve improved it based on your feedback.
--
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]