-
Notifications
You must be signed in to change notification settings - Fork 3k
Configurable metrics reporter by catalog properties #6410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configurable metrics reporter by catalog properties #6410
Conversation
api/src/main/java/org/apache/iceberg/metrics/MetricsReporter.java
Outdated
Show resolved
Hide resolved
hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCatalog.java
Outdated
Show resolved
Hide resolved
api/src/main/java/org/apache/iceberg/metrics/MetricsReporter.java
Outdated
Show resolved
Hide resolved
core/src/main/java/org/apache/iceberg/BaseMetastoreCatalog.java
Outdated
Show resolved
Hide resolved
hive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCatalog.java
Outdated
Show resolved
Hide resolved
nastra
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For testing the custom metrics reporter it would be good to add the following test to TestJdbcCatalog:
+ @Test
+ public void testCatalogWithCustomMetricsReporter() throws IOException {
+ catalog =
+ initCatalog(
+ "test_jdbc_catalog_with_custom_reporter",
+ ImmutableMap.of(
+ CatalogProperties.METRICS_REPORTER_IMPL, CustomMetricsReporter.class.getName()));
+
+ catalog.buildTable(TABLE, SCHEMA).create();
+ Table table = catalog.loadTable(TABLE);
+ table
+ .newFastAppend()
+ .appendFile(
+ DataFiles.builder(PartitionSpec.unpartitioned())
+ .withPath("/path/to/data-a.parquet")
+ .withFileSizeInBytes(10)
+ .withRecordCount(2)
+ .build())
+ .commit();
+
+ try (CloseableIterable<FileScanTask> tasks = table.newScan().planFiles()) {
+ assertThat(tasks.iterator()).hasNext();
+ }
+
+ // counter of custom metrics reporter should have been increased
+ // 1x for commit metrics / 1x for scan metrics
+ assertThat(CustomMetricsReporter.COUNTER.get()).isEqualTo(2);
+ }
+
+ public static class CustomMetricsReporter implements MetricsReporter {
+ static final AtomicInteger COUNTER = new AtomicInteger(0);
+
+ @Override
+ public void report(MetricsReport report) {
+ COUNTER.incrementAndGet();
+ }
+ }
core/src/main/java/org/apache/iceberg/BaseMetastoreCatalog.java
Outdated
Show resolved
Hide resolved
nastra
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with some nits.
@rdblue could you review this one please?
core/src/main/java/org/apache/iceberg/BaseMetastoreCatalog.java
Outdated
Show resolved
Hide resolved
|
Can I please get another review for merge to get enabled? |
PraveenNanda124
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
|
@gaborkaszab Can you please get this merged? |
The patch LGTM, however, I won't be able to merge as I'm not a committer. cc @rdblue |
|
I think its fine with me if we can fix the failures |
|
@gaborkaszab @szehon-ho Could you please trigger workflows? |
|
@kmozaid could you rebase the PR please? |
|
@nastra I have rebased PR. |
| } | ||
|
|
||
| @Override | ||
| protected Map<String, String> properties() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused, because the changes in this file should be gone after a rebase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, I didn't build locally.
thanks, I agree it should be gone. Fixed it.
|
Merged, thanks @kmozaid , also @nastra , @gaborkaszab , @PraveenNanda124 for reviews |
No description provided.