Skip to content

feat: metrics reporting for scan and commit#589

Open
evindj wants to merge 3 commits into
apache:mainfrom
evindj:metrics_core_components
Open

feat: metrics reporting for scan and commit#589
evindj wants to merge 3 commits into
apache:mainfrom
evindj:metrics_core_components

Conversation

@evindj
Copy link
Copy Markdown
Contributor

@evindj evindj commented Mar 11, 2026

Initial commit for addressing #533

@evindj evindj marked this pull request as draft March 11, 2026 20:33
@evindj evindj force-pushed the metrics_core_components branch from 5fa02cb to 0a85180 Compare March 11, 2026 20:48
@wgtmac
Copy link
Copy Markdown
Member

wgtmac commented Mar 20, 2026

Let me know when ready for review :)

@evindj
Copy link
Copy Markdown
Contributor Author

evindj commented Mar 21, 2026

Let me know when ready for review :)

for sure ! most likely tomorrow

@evindj evindj force-pushed the metrics_core_components branch 2 times, most recently from 5241044 to d26fb96 Compare March 25, 2026 03:15
@evindj evindj marked this pull request as ready for review March 25, 2026 04:08
@wgtmac
Copy link
Copy Markdown
Member

wgtmac commented Mar 27, 2026

Thanks for updating this! I still need to take some time to get familiar with the Java implementation and its API in the rest spec before reviewing it.

Copy link
Copy Markdown
Member

@wgtmac wgtmac left a comment

Choose a reason for hiding this comment

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

Thanks for working on this! I have some general questions on the design, especially on the capability of customization. IMO we can focus on the API design for now and later integrate with other classes. Please let me know what you think.

Comment thread src/iceberg/metrics_reporter.h Outdated
Comment thread src/iceberg/metrics_reporter.h Outdated
Comment thread src/iceberg/metrics_reporter.h Outdated
Comment thread src/iceberg/metrics_reporter.h Outdated
Comment thread src/iceberg/metrics_reporter.h Outdated
Comment thread src/iceberg/metrics_reporter.h Outdated
Comment thread src/iceberg/metrics_reporter.h Outdated
Comment thread src/iceberg/metrics_reporter.h Outdated
Comment thread src/iceberg/metrics_reporter.h Outdated
///
/// \param reporter_type Case-insensitive type identifier (e.g., "noop").
/// \param factory Factory function that produces the reporter.
static void Register(std::string_view reporter_type, MetricsReporterFactory factory);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How do we support the Java parity CompositeMetricsReporter? It would be useful if we want to report metrics to multiple sinks.

@evindj
Copy link
Copy Markdown
Contributor Author

evindj commented Mar 31, 2026

Thanks for working on this! I have some general questions on the design, especially on the capability of customization. IMO we can focus on the API design for now and later integrate with other classes. Please let me know what you think.

This is fair, I just wanted to show the end to end picture for ease of understanding.

@evindj evindj marked this pull request as draft March 31, 2026 13:59
@evindj evindj marked this pull request as ready for review April 2, 2026 05:08
Comment thread src/iceberg/metrics/CMakeLists.txt
Copy link
Copy Markdown
Member

@wgtmac wgtmac left a comment

Choose a reason for hiding this comment

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

Follow-up findings from a deeper design/parity pass over the metrics reporting changes.

Comment thread src/iceberg/transaction.cc Outdated
Comment thread src/iceberg/catalog/rest/rest_catalog.cc Outdated
Comment thread src/iceberg/metrics/metrics_reporters.cc
Comment thread src/iceberg/metrics/scan_report.h Outdated
Comment thread src/iceberg/transaction.cc Outdated
Comment thread src/iceberg/table_scan.cc Outdated
Comment thread src/iceberg/metrics/commit_report.h Outdated
Comment thread src/iceberg/table_scan.h
@wgtmac
Copy link
Copy Markdown
Member

wgtmac commented Apr 17, 2026

I have a design question about the ScanReport / CommitReport model in this PR. What is the intended direction here with respect to the Java metrics API? In Java, the reporting model is layered around metrics collection/result types, which also carry unit information and are backed by reusable measurement utilities (for example counters/timers and the related conversion helpers). In this C++ version, the reports currently look more like raw result structs, and I do not yet see an equivalent measurement abstraction/tooling layer behind them. Is that divergence intentional for C++, or is this PR meant as an initial step toward a closer alignment with the Java design over time?

@evindj
Copy link
Copy Markdown
Contributor Author

evindj commented Apr 18, 2026

I have a design question about the ScanReport / CommitReport model in this PR. What is the intended direction here with respect to the Java metrics API? In Java, the reporting model is layered around metrics collection/result types, which also carry unit information and are backed by reusable measurement utilities (for example counters/timers and the related conversion helpers). In this C++ version, the reports currently look more like raw result structs, and I do not yet see an equivalent measurement abstraction/tooling layer behind them. Is that divergence intentional for C++, or is this PR meant as an initial step toward a closer alignment with the Java design over time?

The plan is still to keep parity as a next step I was thinking of doing serialization and then introduce the utilities. I initially elected to do it this way because I wanted to have an idea of the end to end view. Now I can probably update the first initial PR to just on the utilities if it will make your review easier I also don't want the change to be too big.

@wgtmac
Copy link
Copy Markdown
Member

wgtmac commented Apr 28, 2026

@evindj Sorry I've been busy these days. I think it would be good to focus on the API design first.

std::shared_ptr<FileIO> file_io_;
std::string warehouse_location_;
std::unique_ptr<class InMemoryNamespace> root_namespace_;
std::shared_ptr<MetricsReporter> reporter_;
Copy link
Copy Markdown

@kamcheungting-db kamcheungting-db May 4, 2026

Choose a reason for hiding this comment

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

please add comment about this new member

namespace {

/// \brief Registry type for MetricsReporter factories.
using MetricsReporterRegistry = std::unordered_map<std::string, MetricsReporterFactory>;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

why not use enum as the key?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Do we have any use case that std::string fit better?

Comment thread src/iceberg/table.h
/// \param[in] metadata The metadata for the table.
/// \param[in] metadata_location The location of the table metadata file.
/// \param[in] io The FileIO to read and write table data and metadata files.
/// \param[in] catalog The catalog that this table belongs to.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

update comment of parameter list

Comment thread src/iceberg/table_scan.cc Outdated
std::shared_ptr<TableMetadata> table_metadata, std::shared_ptr<FileIO> file_io,
std::shared_ptr<MetricsReporter> reporter, const std::string& table_name)
: metadata_(std::move(table_metadata)), io_(std::move(file_io)) {
context_.reporter = std::move(reporter);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

should we also check port reporter like table.h above?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Just want to make all usage of reporter to be consistent

Comment thread src/iceberg/table_scan.cc Outdated
Comment on lines +564 to +567
report.scan_metrics.total_data_manifests =
static_cast<int64_t>(data_manifests.size());
report.scan_metrics.total_delete_manifests =
static_cast<int64_t>(delete_manifests.size());
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

if the source of the data are not int64_t, why do we declare them as int64_t ?
It looke like unnecessary type casting?

@wgtmac
Copy link
Copy Markdown
Member

wgtmac commented May 12, 2026

@evindj Do you have any chance to revive this?

@evindj
Copy link
Copy Markdown
Contributor Author

evindj commented May 12, 2026

@evindj Do you have any chance to revive this?

Sorry for the long wait, I have been a bit busy lately. My schedule should clear toward the end of the week.

@evindj evindj force-pushed the metrics_core_components branch 4 times, most recently from f787939 to dbf02c0 Compare May 21, 2026 18:24
Copy link
Copy Markdown
Member

@wgtmac wgtmac left a comment

Choose a reason for hiding this comment

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

I haven't finished my review yet. Just post my findings so far and I'll finish it in two days. I think this change looks great. Thank you for polishing the design!

Comment thread src/iceberg/metrics/timer.h Outdated
Comment thread src/iceberg/metrics/counter.h Outdated
Comment thread src/iceberg/metrics/counter.h Outdated
Comment thread src/iceberg/metrics/counter.h Outdated
Comment thread src/iceberg/metrics/timer.h Outdated
Comment thread src/iceberg/metrics/scan_report.h Outdated
class ICEBERG_EXPORT ScanMetrics {
public:
/// \brief Create a ScanMetrics instance backed by the given MetricsContext.
static ScanMetrics Of(MetricsContext& context);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we return std::unique_ptr<ScanMetrics> instead? Downstream is free to choose unique_ptr or shared_ptr then.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we want to make the default ctor private?

Comment thread src/iceberg/metrics/scan_report.cc Outdated
Comment thread src/iceberg/metrics/json_serde_internal.h
Copy link
Copy Markdown
Member

@wgtmac wgtmac left a comment

Choose a reason for hiding this comment

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

I've finished reviewing on non-test files. Great work! Let me know what you think. Thanks!

Comment thread src/iceberg/metrics/metrics_context.h Outdated
Comment thread src/iceberg/metrics/metrics_context.h Outdated
Comment thread src/iceberg/metrics/metrics_context.h Outdated
Comment thread src/iceberg/metrics/metrics_reporter.h Outdated
Comment thread src/iceberg/metrics/metrics_reporters.h
Comment thread src/iceberg/metrics/metrics_reporters.h Outdated
Comment thread src/iceberg/metrics/metrics_reporters.h Outdated
@wgtmac wgtmac added the awaiting author action Author needs to address comments, resolve conflicts, answer questions, etc. label May 28, 2026
@evindj evindj force-pushed the metrics_core_components branch from b87f96a to b87c145 Compare May 28, 2026 23:34
@evindj evindj requested a review from wgtmac May 29, 2026 21:28
@wgtmac wgtmac force-pushed the metrics_core_components branch from 64c2353 to f600898 Compare June 5, 2026 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting author action Author needs to address comments, resolve conflicts, answer questions, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants