stevenzwu commented on code in PR #6764: URL: https://github.com/apache/iceberg/pull/6764#discussion_r1100291622
########## flink/v1.16/flink/src/main/java/org/apache/iceberg/flink/sink/IcebergFilesCommitterMetrics.java: ########## @@ -54,12 +60,38 @@ void commitDuration(long commitDurationMs) { lastCommitDurationMs.set(commitDurationMs); } + /** This is called upon a successful commit. */ void updateCommitSummary(CommitSummary stats) { + elapsedSecondsSinceLastSuccessfulCommit.refreshLastRecordedTime(); committedDataFilesCount.inc(stats.dataFilesCount()); committedDataFilesRecordCount.inc(stats.dataFilesRecordCount()); committedDataFilesByteCount.inc(stats.dataFilesByteCount()); committedDeleteFilesCount.inc(stats.deleteFilesCount()); committedDeleteFilesRecordCount.inc(stats.deleteFilesRecordCount()); committedDeleteFilesByteCount.inc(stats.deleteFilesByteCount()); } + + /** + * This gauge measures the elapsed time between now and last recorded time + * set by {@link ElapsedTimeGauge#refreshLastRecordedTime()}. + */ + private static class ElapsedTimeGauge implements Gauge<Long> { + private final TimeUnit reportUnit; + private volatile long lastRecordedTimeNano; + + ElapsedTimeGauge(TimeUnit timeUnit) { + this.reportUnit = timeUnit; + this.lastRecordedTimeNano = System.nanoTime(); + } + + void refreshLastRecordedTime() { Review Comment: @pvary I renamed this method from `refreshLastSuccessfulCommitTime` to `refreshLastRecordedTime`, as the class `ElapsedTimeGauge` was intended as a more general gauge. -- 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: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org