You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2022/10/29 14:42:19 UTC
[GitHub] [druid] 599166320 commented on a diff in pull request #13286: PrometheusEmitter NullPointerException fix
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: commits-unsubscribe@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org