bsyk commented on code in PR #17847:
URL: https://github.com/apache/druid/pull/17847#discussion_r2023350568


##########
server/src/main/java/org/apache/druid/segment/realtime/SegmentGenerationMetrics.java:
##########
@@ -110,6 +116,14 @@ public void reportMessageMaxTimestamp(long 
messageMaxTimestamp)
     this.messageMaxTimestamp.set(Math.max(messageMaxTimestamp, 
this.messageMaxTimestamp.get()));
   }
 
+  public void reportMessageGapAggregate(long messageGap)
+  {
+    final long newNumEvents = this.numMessageGapEvents.incrementAndGet();
+    this.minMessageGap.getAndAccumulate(messageGap, Math::min);
+    this.maxMessageGap.getAndAccumulate(messageGap, Math::max);
+    this.messageGapAvg.getAndUpdate(oldAvg -> oldAvg + ((messageGap - oldAvg) 
/ newNumEvents));

Review Comment:
   Should we compute and store the running average as a Double to avoid 
rounding losses when `newNumEvents` gets large? The metric can still be 
reported as a Long when accessed.



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