3737#include " iceberg/catalog/rest/rest_util.h"
3838#include " iceberg/catalog/rest/types.h"
3939#include " iceberg/json_serde_internal.h"
40+ #include " iceberg/metrics_reporters.h"
4041#include " iceberg/partition_spec.h"
4142#include " iceberg/result.h"
4243#include " iceberg/schema.h"
@@ -168,10 +169,17 @@ Result<std::shared_ptr<RestCatalog>> RestCatalog::Make(
168169 ICEBERG_ASSIGN_OR_RAISE (auto catalog_session,
169170 auth_manager->CatalogSession (*client, final_config.configs ()));
170171
172+ // Load metrics reporter from catalog properties
173+ std::shared_ptr<MetricsReporter> reporter;
174+ auto reporter_result = MetricsReporters::Load (final_config.configs ());
175+ if (reporter_result.has_value ()) {
176+ reporter = std::move (reporter_result.value ());
177+ }
178+
171179 return std::shared_ptr<RestCatalog>(
172180 new RestCatalog (std::move (final_config), std::move (file_io), std::move (client),
173181 std::move (paths), std::move (endpoints), std::move (auth_manager),
174- std::move (catalog_session), snapshot_mode));
182+ std::move (catalog_session), std::move (reporter), snapshot_mode));
175183}
176184
177185RestCatalog::RestCatalog (RestCatalogProperties config, std::shared_ptr<FileIO> file_io,
@@ -180,6 +188,7 @@ RestCatalog::RestCatalog(RestCatalogProperties config, std::shared_ptr<FileIO> f
180188 std::unordered_set<Endpoint> endpoints,
181189 std::unique_ptr<auth::AuthManager> auth_manager,
182190 std::shared_ptr<auth::AuthSession> catalog_session,
191+ std::shared_ptr<MetricsReporter> reporter,
183192 SnapshotMode snapshot_mode)
184193 : config_(std::move(config)),
185194 file_io_ (std::move(file_io)),
@@ -189,6 +198,7 @@ RestCatalog::RestCatalog(RestCatalogProperties config, std::shared_ptr<FileIO> f
189198 supported_endpoints_(std::move(endpoints)),
190199 auth_manager_(std::move(auth_manager)),
191200 catalog_session_(std::move(catalog_session)),
201+ reporter_(std::move(reporter)),
192202 snapshot_mode_(snapshot_mode) {
193203 ICEBERG_DCHECK (catalog_session_ != nullptr , " catalog_session must not be null" );
194204}
@@ -355,7 +365,8 @@ Result<std::shared_ptr<Table>> RestCatalog::CreateTable(
355365 CreateTableInternal (identifier, schema, spec, order, location,
356366 properties, /* stage_create=*/ false ));
357367 return Table::Make (identifier, std::move (result.metadata ),
358- std::move (result.metadata_location ), file_io_, shared_from_this ());
368+ std::move (result.metadata_location ), file_io_, shared_from_this (),
369+ reporter_);
359370}
360371
361372Result<std::shared_ptr<Table>> RestCatalog::UpdateTable (
@@ -386,7 +397,7 @@ Result<std::shared_ptr<Table>> RestCatalog::UpdateTable(
386397
387398 return Table::Make (identifier, std::move (commit_response.metadata ),
388399 std::move (commit_response.metadata_location ), file_io_,
389- shared_from_this ());
400+ shared_from_this (), reporter_ );
390401}
391402
392403Result<std::shared_ptr<Transaction>> RestCatalog::StageCreateTable (
@@ -400,7 +411,7 @@ Result<std::shared_ptr<Transaction>> RestCatalog::StageCreateTable(
400411 ICEBERG_ASSIGN_OR_RAISE (auto staged_table,
401412 StagedTable::Make (identifier, std::move (result.metadata ),
402413 std::move (result.metadata_location ), file_io_,
403- shared_from_this ()));
414+ shared_from_this (), reporter_ ));
404415 return Transaction::Make (std::move (staged_table), TransactionKind::kCreate );
405416}
406417
@@ -469,7 +480,7 @@ Result<std::shared_ptr<Table>> RestCatalog::LoadTable(const TableIdentifier& ide
469480 ICEBERG_ASSIGN_OR_RAISE (auto load_result, LoadTableResultFromJson (json));
470481 return Table::Make (identifier, std::move (load_result.metadata ),
471482 std::move (load_result.metadata_location ), file_io_,
472- shared_from_this ());
483+ shared_from_this (), reporter_ );
473484}
474485
475486Result<std::shared_ptr<Table>> RestCatalog::RegisterTable (
@@ -492,7 +503,7 @@ Result<std::shared_ptr<Table>> RestCatalog::RegisterTable(
492503 ICEBERG_ASSIGN_OR_RAISE (auto load_result, LoadTableResultFromJson (json));
493504 return Table::Make (identifier, std::move (load_result.metadata ),
494505 std::move (load_result.metadata_location ), file_io_,
495- shared_from_this ());
506+ shared_from_this (), reporter_ );
496507}
497508
498509} // namespace iceberg::rest
0 commit comments