abhishekrb19 commented on code in PR #18719:
URL: https://github.com/apache/druid/pull/18719#discussion_r2496506808
##########
extensions-contrib/prometheus-emitter/src/main/java/org/apache/druid/emitter/prometheus/PrometheusEmitter.java:
##########
@@ -179,8 +179,13 @@ private void emitMetric(ServiceMetricEvent metricEvent)
}
if (metric.getCollector() instanceof Counter) {
- ((Counter)
metric.getCollector()).labels(labelValues).inc(value.doubleValue());
- metric.resetLastUpdateTime(Arrays.asList(labelValues));
+ double metricValue = value.doubleValue();
+ if (metricValue >= 0) {
+ ((Counter)
metric.getCollector()).labels(labelValues).inc(metricValue);
+ metric.resetLastUpdateTime(Arrays.asList(labelValues));
+ } else {
+ log.warn("Amount to increment must be non-negative for counter [%s]
with value [%f]", name, metricValue);
Review Comment:
Perhaps something like this:
```suggestion
log.warn("Counter increment amount must be non-negative, but got
value[%f] for metric[%s]. If this is valid, metric should be defined as a gauge
instead of counter.", metricValue, name);
```
--
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]