obelix74 commented on code in PR #3385:
URL: https://github.com/apache/polaris/pull/3385#discussion_r2820065324


##########
runtime/service/src/main/java/org/apache/polaris/service/config/ServiceProducers.java:
##########
@@ -224,6 +227,55 @@ public PolarisMetaStoreManager polarisMetaStoreManager(
     return metaStoreManagerFactory.getOrCreateMetaStoreManager(realmContext);
   }
 
+  /**
+   * Produces a no-op {@link MetricsPersistence} bean.
+   *
+   * <p>This bean is selected when {@code polaris.persistence.metrics.type} is 
set to {@code "noop"}
+   * (the default). All write operations are silently ignored, and all query 
operations return empty
+   * pages.
+   *
+   * @return the no-op MetricsPersistence singleton
+   */
+  @Produces
+  @Identifier("noop")
+  public MetricsPersistence noopMetricsPersistence() {
+    return MetricsPersistence.NOOP;
+  }
+
+  /**
+   * Produces a no-op {@link MetricsSchemaBootstrap} bean.
+   *
+   * <p>This bean is selected for backends that don't support metrics schema 
bootstrap. The {@link
+   * MetricsSchemaBootstrap#bootstrap(String)} method does nothing, and {@link
+   * MetricsSchemaBootstrap#isBootstrapped(String)} always returns {@code 
true}.
+   *
+   * @return the no-op MetricsSchemaBootstrap singleton
+   */
+  @Produces
+  @Identifier("noop")
+  public MetricsSchemaBootstrap noopMetricsSchemaBootstrap() {
+    return MetricsSchemaBootstrap.NOOP;
+  }
+
+  /**
+   * Produces a {@link MetricsPersistence} bean for the current request.
+   *
+   * <p>This method selects a MetricsPersistence implementation based on the 
configured metrics
+   * persistence type. The type is configured independently from the entity 
metastore via {@code
+   * polaris.persistence.metrics.type}.
+   *
+   * @param config the metrics persistence configuration
+   * @param metricsPersistenceImpls all available MetricsPersistence 
implementations
+   * @return a MetricsPersistence implementation for the current realm
+   */
+  @Produces
+  @RequestScoped
+  public MetricsPersistence metricsPersistence(
+      MetricsPersistenceConfiguration config,
+      @Any Instance<MetricsPersistence> metricsPersistenceImpls) {
+    return 
metricsPersistenceImpls.select(Identifier.Literal.of(config.type())).get();

Review Comment:
   Added MetricsPersistenceFactory and MetricsReporterFactory as 
@ApplicationScoped factories that resolve the bean selector once at startup. 
The producers now just call factory.create(), which is a lightweight operation.
   Commit: 249c58a6a



-- 
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]

Reply via email to