Aggarwal-Raghav commented on code in PR #6461:
URL: https://github.com/apache/hive/pull/6461#discussion_r3186280052


##########
standalone-metastore/metastore-rest-catalog/src/main/java/org/apache/iceberg/rest/HMSCatalogFactory.java:
##########
@@ -109,7 +116,24 @@ private HttpServlet createServlet(Catalog catalog) {
     // Iceberg REST client uses "catalog" by default
     List<String> scopes = Collections.singletonList("catalog");
     ServletSecurity security = new 
ServletSecurity(AuthType.fromString(authType), configuration, req -> scopes);
-    return security.proxy(new HMSCatalogServlet(new 
HMSCatalogAdapter(catalog)));
+    String catalogName = MetastoreConf.getVar(configuration, 
ConfVars.CATALOG_DEFAULT);
+    List<IcebergMetricsReporter> reporters = createReporters();
+    return security.proxy(new HMSCatalogServlet(new 
HMSCatalogAdapter(catalogName, catalog, reporters)));
+  }
+
+  private List<IcebergMetricsReporter> createReporters() {
+    final var classes = configuration.getClasses(
+        ConfVars.ICEBERG_CATALOG_METRICS_REPORTERS.getVarname(),
+        LoggingMetricsReporter.class
+    );
+    return Arrays.stream(classes).map(clazz -> {
+      try {
+        final var constructor = 
clazz.getDeclaredConstructor(Configuration.class);
+        return (IcebergMetricsReporter) constructor.newInstance(configuration);
+      } catch (NoSuchMethodException | InstantiationException | 
IllegalAccessException | InvocationTargetException e) {
+        throw new IllegalArgumentException("Failed to instantiate 
IcebergMetricsReporter: {}" + clazz.getName(), e);

Review Comment:
   Remove the `{}`
   ```throw new IllegalArgumentException("Failed to instantiate 
IcebergMetricsReporter: " + clazz.getName(), e);```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to