599166320 commented on code in PR #13286:
URL: https://github.com/apache/druid/pull/13286#discussion_r1008710907


##########
extensions-contrib/prometheus-emitter/src/main/java/org/apache/druid/emitter/prometheus/PrometheusEmitter.java:
##########
@@ -57,7 +58,7 @@ public class PrometheusEmitter implements Emitter
 
   private HTTPServer server;
   private PushGateway pushGateway;
-  private String identifier;
+  private volatile String identifier;

Review Comment:
   The existence of multiple threads calling emitMetric will modify the 
`identifier`. Even if the `identifier` is modified countless times, there will 
always be only one result, which is an `idempotent design`.
   Currently only the thread of `PrometheusPushGatewayEmitter` will read the 
value of `identifier`. In order to guarantee the visibility of the reading 
thread, I use volatile to decorate the `identifier`.
   
   In addition, there is an inefficient way to use LinkedBlockingQueue to 
achieve safe publishing. This is how `InfluxdbEmitter` is implemented.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to