Skip to content

Commit

Permalink
[HUDI-5201] Add totalRecordsDeleted metric (#7181)
Browse files Browse the repository at this point in the history
  • Loading branch information
hussein-awala authored Nov 14, 2022
1 parent b10a7c3 commit 5ac605c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ public void updateMetricsForEmptyData(String actionType) {
Metrics.registerGauge(getMetricsName(actionType, "totalRecordsWritten"), 0);
Metrics.registerGauge(getMetricsName(actionType, "totalUpdateRecordsWritten"), 0);
Metrics.registerGauge(getMetricsName(actionType, "totalInsertRecordsWritten"), 0);
Metrics.registerGauge(getMetricsName(actionType, "totalRecordsDeleted"), 0);
Metrics.registerGauge(getMetricsName(actionType, "totalBytesWritten"), 0);
Metrics.registerGauge(getMetricsName(actionType, "totalScanTime"), 0);
Metrics.registerGauge(getMetricsName(actionType, "totalCreateTime"), 0);
Expand All @@ -187,6 +188,7 @@ public void updateCommitMetrics(long commitEpochTimeInMs, long durationInMs, Hoo
long totalRecordsWritten = metadata.fetchTotalRecordsWritten();
long totalUpdateRecordsWritten = metadata.fetchTotalUpdateRecordsWritten();
long totalInsertRecordsWritten = metadata.fetchTotalInsertRecordsWritten();
long totalRecordsDeleted = metadata.getTotalRecordsDeleted();
long totalBytesWritten = metadata.fetchTotalBytesWritten();
long totalTimeTakenByScanner = metadata.getTotalScanTime();
long totalTimeTakenForInsert = metadata.getTotalCreateTime();
Expand All @@ -207,6 +209,7 @@ public void updateCommitMetrics(long commitEpochTimeInMs, long durationInMs, Hoo
Metrics.registerGauge(getMetricsName(actionType, "totalCompactedRecordsUpdated"), totalCompactedRecordsUpdated);
Metrics.registerGauge(getMetricsName(actionType, "totalLogFilesCompacted"), totalLogFilesCompacted);
Metrics.registerGauge(getMetricsName(actionType, "totalLogFilesSize"), totalLogFilesSize);
Metrics.registerGauge(getMetricsName(actionType, "totalRecordsDeleted"), totalRecordsDeleted);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,9 @@ public void testTimerCtx() throws InterruptedException {
when(metadata.getTotalCompactedRecordsUpdated()).thenReturn(randomValue + 11);
when(metadata.getTotalLogFilesCompacted()).thenReturn(randomValue + 12);
when(metadata.getTotalLogFilesSize()).thenReturn(randomValue + 13);
when(metadata.getTotalRecordsDeleted()).thenReturn(randomValue + 14);
when(metadata.getMinAndMaxEventTime()).thenReturn(Pair.of(Option.empty(), Option.empty()));
metrics.updateCommitMetrics(randomValue + 14, commitTimer.stop(), metadata, action);
metrics.updateCommitMetrics(randomValue + 15, commitTimer.stop(), metadata, action);

String metricname = metrics.getMetricsName(action, "duration");
long duration = (Long)Metrics.getInstance().getRegistry().getGauges().get(metricname).getValue();
Expand All @@ -158,7 +159,7 @@ public void testTimerCtx() throws InterruptedException {
metricname = metrics.getMetricsName(action, "totalBytesWritten");
assertEquals((long)Metrics.getInstance().getRegistry().getGauges().get(metricname).getValue(), metadata.fetchTotalBytesWritten());
metricname = metrics.getMetricsName(action, "commitTime");
assertEquals((long)Metrics.getInstance().getRegistry().getGauges().get(metricname).getValue(), randomValue + 14);
assertEquals((long)Metrics.getInstance().getRegistry().getGauges().get(metricname).getValue(), randomValue + 15);
metricname = metrics.getMetricsName(action, "totalScanTime");
assertEquals(Metrics.getInstance().getRegistry().getGauges().get(metricname).getValue(), metadata.getTotalScanTime());
metricname = metrics.getMetricsName(action, "totalCreateTime");
Expand All @@ -171,6 +172,8 @@ public void testTimerCtx() throws InterruptedException {
assertEquals(Metrics.getInstance().getRegistry().getGauges().get(metricname).getValue(), metadata.getTotalLogFilesCompacted());
metricname = metrics.getMetricsName(action, "totalLogFilesSize");
assertEquals(Metrics.getInstance().getRegistry().getGauges().get(metricname).getValue(), metadata.getTotalLogFilesSize());
metricname = metrics.getMetricsName(action, "totalRecordsDeleted");
assertEquals(Metrics.getInstance().getRegistry().getGauges().get(metricname).getValue(), metadata.getTotalRecordsDeleted());
});
}
}

0 comments on commit 5ac605c

Please sign in to comment.