Skip to content

Commit

Permalink
[core] Add close method for CommitMetrics
Browse files Browse the repository at this point in the history
  • Loading branch information
schnappi17 committed Oct 19, 2023
1 parent 5992c96 commit 7e8319c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public CommitMetrics(String tableName) {
registerGenericCommitMetrics();
}

@VisibleForTesting
public AbstractMetricGroup getMetricGroup() {
return genericMetricGroup;
}
Expand Down Expand Up @@ -129,4 +130,8 @@ public void reportCommit(CommitStats commitStats) {
latestCommit = commitStats;
durationHistogram.update(commitStats.getDuration());
}

public void close() {
this.genericMetricGroup.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public void close() throws Exception {
}
IOUtils.closeQuietly(lock);
expireMainExecutor.shutdownNow();
commitMetrics.getMetricGroup().close();
commitMetrics.close();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.paimon.metrics.MetricGroup;
import org.apache.paimon.metrics.Metrics;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand All @@ -45,10 +46,14 @@ public class CommitMetricsTest {

@BeforeEach
public void beforeEach() {
Metrics.getInstance().getMetricGroups().clear();
commitMetrics = getCommitMetrics();
}

@AfterEach
public void afterEach() {
commitMetrics.close();
}

/** Tests the registration of the commit metrics. */
@Test
public void testGenericMetricsRegistration() {
Expand Down

0 comments on commit 7e8319c

Please sign in to comment.