ffang commented on code in PR #2669:
URL: https://github.com/apache/cxf/pull/2669#discussion_r2443553081


##########
rt/features/metrics/src/main/java/org/apache/cxf/metrics/ExchangeMetrics.java:
##########
@@ -40,9 +40,11 @@ public ExchangeMetrics(Exchange e) {
     }
 
     public ExchangeMetrics addContext(MetricsContext ctx) {
-        contexts.addLast(ctx);
-        if (started) {
-            ctx.start(exchange);
+        if (!contexts.contains(ctx)) {

Review Comment:
   Hi @reta ,
   
   Because to address CXF-9168, we create the MicrometerMetrics early for the 
endpoint, just in case the incoming mesasge parsing failed early in the 
interceptor chain, when the operationName not get parsed yet and no chance to 
create it for the operation.
   
   But for the the normal successful request, we check the MicrometerMetrics 
from the endpoint first, if exists there, just reuse it. But current logic will 
try to add the reused MetricsContext again to the ExchangeMetrics, that's why I 
add code to prevent the same MetricsContext from being added(I see it as kinda 
safety net). 
   
   Thanks!
   Freeman



-- 
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