Skip to content

Configurable metrics reporter by catalog properties - #6410

Merged
szehon-ho merged 9 commits into
apache:masterfrom
kmozaid:feature/custom-metric-reporter
Feb 9, 2023
Merged

Configurable metrics reporter by catalog properties#6410
szehon-ho merged 9 commits into
apache:masterfrom
kmozaid:feature/custom-metric-reporter

Conversation

@kmozaid

Copy link
Copy Markdown
Contributor

No description provided.

Comment threadapi/src/main/java/org/apache/iceberg/metrics/MetricsReporter.java Outdated
Comment threadcore/src/main/java/org/apache/iceberg/BaseTable.java Outdated
Comment threadhive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCatalog.java Outdated
Comment threadapi/src/main/java/org/apache/iceberg/metrics/MetricsReporter.java Outdated
Comment threadcore/src/main/java/org/apache/iceberg/BaseMetastoreCatalog.java Outdated
Comment threadhive-metastore/src/test/java/org/apache/iceberg/hive/TestHiveCatalog.java Outdated
Comment threadcore/src/main/java/org/apache/iceberg/BaseTable.java Outdated
@nastra

Copy link
Copy Markdown
Contributor

@kmozaid now that #6404 is merged, can you please rebase this PR?

@github-actionsgithub-actionsBot removed the API label Dec 21, 2022
@kmozaid

Copy link
Copy Markdown
ContributorAuthor

@kmozaid now that #6404 is merged, can you please rebase this PR?

Hi @nastra I have rebased and updated PR with feedbacks.

@kmozaid
kmozaid requested review from gaborkaszab and nastra and removed request for gaborkaszab and nastraDecember 21, 2022 12:59

@nastranastra left a comment

Copy link
Copy Markdown
Contributor

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();
+ }
+ }

Comment threadcore/src/main/java/org/apache/iceberg/BaseMetastoreCatalog.java Outdated
@nastra

Copy link
Copy Markdown
Contributor

@kmozaid while reviewing this PR I've noticed that not every catalog actually exposes its properties (including the JDBC catalog which I suggested above to use for testing). I've opened #6471 to address that

@kmozaid
kmozaid requested a review from nastraDecember 21, 2022 17:05

@nastranastra left a comment

Copy link
Copy Markdown
Contributor

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?

Comment threadcore/src/main/java/org/apache/iceberg/BaseMetastoreCatalog.java Outdated
@nastra
nastra requested a review from rdblueDecember 21, 2022 17:11
@kmozaid

Copy link
Copy Markdown
ContributorAuthor

Can I please get another review for merge to get enabled?

@PraveenNanda124PraveenNanda124 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@kmozaid

Copy link
Copy Markdown
ContributorAuthor

@gaborkaszab Can you please get this merged?

@gaborkaszab

Copy link
Copy Markdown
Contributor

@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

@szehon-ho

Copy link
Copy Markdown
Member

I think its fine with me if we can fix the failures

@kmozaid

Copy link
Copy Markdown
ContributorAuthor

@gaborkaszab@szehon-ho Could you please trigger workflows?

@nastra

Copy link
Copy Markdown
Contributor

@kmozaid could you rebase the PR please?
@danielcweeks could you review this please when you get a chance (and also trigger CI)?

@kmozaid

Copy link
Copy Markdown
ContributorAuthor

@nastra I have rebased PR.

}

@Override
protected Map<String, String> properties() {

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
ContributorAuthor

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.

@szehon-ho
szehon-ho merged commit 03443f5 into apache:masterFeb 9, 2023
@szehon-ho

ghost commented Feb 9, 2023

Copy link
Copy Markdown
Member

Merged, thanks @kmozaid , also @nastra , @gaborkaszab , @PraveenNanda124 for reviews

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@kmozaid@nastra@gaborkaszab@szehon-ho@PraveenNanda124