NicoK commented on a change in pull request #8886: [FLINK-12987][metrics] fix DescriptiveStatisticsHistogram#getCount() not returning the number of elements seen URL: https://github.com/apache/flink/pull/8886#discussion_r314395738
########## File path: flink-runtime/src/main/java/org/apache/flink/runtime/metrics/DescriptiveStatisticsHistogram.java ########## @@ -22,25 +22,30 @@ import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics; +import java.util.concurrent.atomic.AtomicLong; + /** * The {@link DescriptiveStatisticsHistogram} use a DescriptiveStatistics {@link DescriptiveStatistics} as a Flink {@link Histogram}. */ public class DescriptiveStatisticsHistogram implements org.apache.flink.metrics.Histogram { private final DescriptiveStatistics descriptiveStatistics; + private final AtomicLong elementsSeen = new AtomicLong(); Review comment: Seems like the underlying code is not thread-safe anyways and we provide only best-effort metrics. I reverted to just using a `long` now. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services