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"
@@ -154,25 +155,35 @@ Result<std::shared_ptr<RestCatalog>> RestCatalog::Make(
154155 ICEBERG_ASSIGN_OR_RAISE (auto catalog_session,
155156 auth_manager->CatalogSession (*client, final_config.configs ()));
156157
157- return std::shared_ptr<RestCatalog>(new RestCatalog (
158- std::move (final_config), std::move (file_io), std::move (client), std::move (paths),
159- std::move (endpoints), std::move (auth_manager), std::move (catalog_session)));
158+ // Load metrics reporter from catalog properties
159+ std::shared_ptr<MetricsReporter> reporter;
160+ auto reporter_result = MetricsReporters::Load (final_config.configs ());
161+ if (reporter_result.has_value ()) {
162+ reporter = std::move (reporter_result.value ());
163+ }
164+
165+ return std::shared_ptr<RestCatalog>(
166+ new RestCatalog (std::move (final_config), std::move (file_io), std::move (client),
167+ std::move (paths), std::move (endpoints), std::move (auth_manager),
168+ std::move (catalog_session), std::move (reporter)));
160169}
161170
162171RestCatalog::RestCatalog (RestCatalogProperties config, std::shared_ptr<FileIO> file_io,
163172 std::unique_ptr<HttpClient> client,
164173 std::unique_ptr<ResourcePaths> paths,
165174 std::unordered_set<Endpoint> endpoints,
166175 std::unique_ptr<auth::AuthManager> auth_manager,
167- std::shared_ptr<auth::AuthSession> catalog_session)
176+ std::shared_ptr<auth::AuthSession> catalog_session,
177+ std::shared_ptr<MetricsReporter> reporter)
168178 : config_(std::move(config)),
169179 file_io_ (std::move(file_io)),
170180 client_(std::move(client)),
171181 paths_(std::move(paths)),
172182 name_(config_.Get(RestCatalogProperties::kName )),
173183 supported_endpoints_(std::move(endpoints)),
174184 auth_manager_(std::move(auth_manager)),
175- catalog_session_(std::move(catalog_session)) {
185+ catalog_session_(std::move(catalog_session)),
186+ reporter_(std::move(reporter)) {
176187 ICEBERG_DCHECK (catalog_session_ != nullptr , " catalog_session must not be null" );
177188}
178189
@@ -338,7 +349,8 @@ Result<std::shared_ptr<Table>> RestCatalog::CreateTable(
338349 CreateTableInternal (identifier, schema, spec, order, location,
339350 properties, /* stage_create=*/ false ));
340351 return Table::Make (identifier, std::move (result.metadata ),
341- std::move (result.metadata_location ), file_io_, shared_from_this ());
352+ std::move (result.metadata_location ), file_io_, shared_from_this (),
353+ reporter_);
342354}
343355
344356Result<std::shared_ptr<Table>> RestCatalog::UpdateTable (
@@ -369,7 +381,7 @@ Result<std::shared_ptr<Table>> RestCatalog::UpdateTable(
369381
370382 return Table::Make (identifier, std::move (commit_response.metadata ),
371383 std::move (commit_response.metadata_location ), file_io_,
372- shared_from_this ());
384+ shared_from_this (), reporter_ );
373385}
374386
375387Result<std::shared_ptr<Transaction>> RestCatalog::StageCreateTable (
@@ -383,7 +395,7 @@ Result<std::shared_ptr<Transaction>> RestCatalog::StageCreateTable(
383395 ICEBERG_ASSIGN_OR_RAISE (auto staged_table,
384396 StagedTable::Make (identifier, std::move (result.metadata ),
385397 std::move (result.metadata_location ), file_io_,
386- shared_from_this ()));
398+ shared_from_this (), reporter_ ));
387399 return Transaction::Make (std::move (staged_table), Transaction::Kind::kCreate ,
388400 /* auto_commit=*/ false );
389401}
@@ -446,7 +458,7 @@ Result<std::shared_ptr<Table>> RestCatalog::LoadTable(const TableIdentifier& ide
446458
447459 return Table::Make (identifier, std::move (load_result.metadata ),
448460 std::move (load_result.metadata_location ), file_io_,
449- shared_from_this ());
461+ shared_from_this (), reporter_ );
450462}
451463
452464Result<std::shared_ptr<Table>> RestCatalog::RegisterTable (
@@ -469,7 +481,7 @@ Result<std::shared_ptr<Table>> RestCatalog::RegisterTable(
469481 ICEBERG_ASSIGN_OR_RAISE (auto load_result, LoadTableResultFromJson (json));
470482 return Table::Make (identifier, std::move (load_result.metadata ),
471483 std::move (load_result.metadata_location ), file_io_,
472- shared_from_this ());
484+ shared_from_this (), reporter_ );
473485}
474486
475487} // namespace iceberg::rest
0 commit comments