mas-chen commented on code in PR #6764: URL: https://github.com/apache/iceberg/pull/6764#discussion_r1099674674
########## flink/v1.16/flink/src/main/java/org/apache/iceberg/flink/sink/IcebergFilesCommitterMetrics.java: ########## @@ -54,12 +60,34 @@ void commitDuration(long commitDurationMs) { lastCommitDurationMs.set(commitDurationMs); } + /** This is called upon a successful commit. */ void updateCommitSummary(CommitSummary stats) { + elapsedSecondsSinceLastSuccessfulCommit.refreshLastSuccessfulCommitTime(); committedDataFilesCount.inc(stats.dataFilesCount()); committedDataFilesRecordCount.inc(stats.dataFilesRecordCount()); committedDataFilesByteCount.inc(stats.dataFilesByteCount()); committedDeleteFilesCount.inc(stats.deleteFilesCount()); committedDeleteFilesRecordCount.inc(stats.deleteFilesRecordCount()); committedDeleteFilesByteCount.inc(stats.deleteFilesByteCount()); } + + private static class ElapsedTimeGauge implements Gauge<Long> { + private final TimeUnit reportUnit; + private volatile long lastSuccessfulCommitTimeNano; + + ElapsedTimeGauge(TimeUnit timeUnit) { + this.reportUnit = timeUnit; + this.lastSuccessfulCommitTimeNano = System.nanoTime(); + } + + void refreshLastSuccessfulCommitTime() { + this.lastSuccessfulCommitTimeNano = System.nanoTime(); + } + + @Override + public Long getValue() { + return reportUnit.convert( Review Comment: No, before the first checkpoint. `lastSuccessfulCommitTimeNano` would be 0 and the delta would be large -- 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