mas-chen commented on code in PR #6764: URL: https://github.com/apache/iceberg/pull/6764#discussion_r1099564976
########## 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: It's possible that this metric may polled by the metric reporter before a single checkpoint has completed. Can that edge case be handled? Reporting a huge number is going to be confusing -- 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