This is an automated email from the ASF dual-hosted git repository.
nodece pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new 00577a5438b [fix][broker] Fix precision loss in
DataSketchesSummaryLogger by replacing LongAdder with DoubleAdder for sum
accumulation (#25594)
00577a5438b is described below
commit 00577a5438bbb3d959e5ca2ea037e760219b95d8
Author: zhenJiangWang <[email protected]>
AuthorDate: Wed Apr 29 10:47:18 2026 +0800
[fix][broker] Fix precision loss in DataSketchesSummaryLogger by replacing
LongAdder with DoubleAdder for sum accumulation (#25594)
---
.../broker/stats/prometheus/metrics/DataSketchesSummaryLogger.java | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/stats/prometheus/metrics/DataSketchesSummaryLogger.java
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/stats/prometheus/metrics/DataSketchesSummaryLogger.java
index 42c189d4bf3..7495f057aa0 100644
---
a/pulsar-broker/src/main/java/org/apache/pulsar/broker/stats/prometheus/metrics/DataSketchesSummaryLogger.java
+++
b/pulsar-broker/src/main/java/org/apache/pulsar/broker/stats/prometheus/metrics/DataSketchesSummaryLogger.java
@@ -22,6 +22,7 @@ import com.yahoo.sketches.quantiles.DoublesSketch;
import com.yahoo.sketches.quantiles.DoublesUnion;
import com.yahoo.sketches.quantiles.DoublesUnionBuilder;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.DoubleAdder;
import java.util.concurrent.atomic.LongAdder;
public class DataSketchesSummaryLogger {
@@ -37,7 +38,7 @@ public class DataSketchesSummaryLogger {
*/
private volatile DoublesSketch values;
private final LongAdder countAdder = new LongAdder();
- private final LongAdder sumAdder = new LongAdder();
+ private final DoubleAdder sumAdder = new DoubleAdder();
public DataSketchesSummaryLogger() {
this.current = new ThreadLocalAccessor();
@@ -48,7 +49,7 @@ public class DataSketchesSummaryLogger {
double valueMillis = unit.toMicros(eventLatency) / 1000.0;
countAdder.increment();
- sumAdder.add((long) valueMillis);
+ sumAdder.add(valueMillis);
current.getLocalData().updateSuccess(valueMillis);
}
@@ -69,7 +70,7 @@ public class DataSketchesSummaryLogger {
return countAdder.sum();
}
- public long getSum() {
+ public double getSum() {
return sumAdder.sum();
}