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


##########
server/src/main/java/org/apache/druid/segment/realtime/appenderator/StreamAppenderator.java:
##########
@@ -288,6 +295,15 @@ public Object startJob()
     initializeExecutors();
     resetNextFlush();
     sinkSchemaAnnouncer.start();
+
+    if (timeExecutor != null) {
+      timeExecutor.scheduleAtFixedRate(
+          () -> currTimeMs = System.currentTimeMillis(),
+          0,
+          1,
+          TimeUnit.MILLISECONDS
+      );

Review Comment:
   There are other cleaner ways to avoid invoking the 
`System.currentTimeMillis()` call.
   They could be somewhat less accurate but good enough for the use case here.
   
   Just initialize the start time once when the message gap is being reset in 
`SegmentGenerationMetrics`.
   Maintain a `Stopwatch`.
   
   When calling `recordMessageLag`, compute message gap as follows:
   
   ```
   messageGap = startTimestamp + stopwatch.millisElapsed() - rowTimestamp
   ```
   
   Let me know if that would work.



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