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


##########
runtime/service/src/main/java/org/apache/polaris/service/reporting/PolarisMetricsReporter.java:
##########
@@ -18,9 +18,84 @@
  */
 package org.apache.polaris.service.reporting;
 
+import java.time.Instant;
 import org.apache.iceberg.catalog.TableIdentifier;
 import org.apache.iceberg.metrics.MetricsReport;
 
+/**
+ * SPI interface for reporting Iceberg metrics received by Polaris.
+ *
+ * <p>Implementations can be used to send metrics to external systems for 
analysis and monitoring.
+ * Custom implementations must be annotated with {@link
+ * jakarta.enterprise.context.ApplicationScoped @ApplicationScoped} and {@link
+ * io.smallrye.common.annotation.Identifier @Identifier("my-reporter-type")} 
for CDI discovery.
+ *
+ * <p>The implementation to use is selected via the {@code 
polaris.iceberg-metrics.reporting.type}
+ * configuration property, which defaults to {@code "default"}.
+ *
+ * <p>Custom implementations that need access to request-scoped context should 
inject the
+ * appropriate CDI beans rather than expecting this data to be passed as 
parameters:
+ *
+ * <ul>
+ *   <li>{@code RealmContext} - for realm/tenant information
+ *   <li>{@code io.opentelemetry.api.trace.Span} - for OpenTelemetry 
trace/span IDs (inject via
+ *       {@code @Inject Span span} or use {@code Span.current()})
+ *   <li>{@code PolarisPrincipalHolder} - for authenticated principal 
information
+ * </ul>
+ *
+ * <p>Example implementation with OpenTelemetry correlation:
+ *
+ * <pre>{@code
+ * @ApplicationScoped
+ * @Identifier("custom")
+ * public class CustomMetricsReporter implements PolarisMetricsReporter {
+ *
+ *   @Inject RealmContext realmContext;
+ *   @Inject Span span; // or use Span.current()
+ *
+ *   @Override
+ *   public void reportMetric(
+ *       String catalogName, TableIdentifier table, MetricsReport 
metricsReport,
+ *       Instant receivedTimestamp) {
+ *     SpanContext spanContext = span.getSpanContext();
+ *     String traceId = spanContext.isValid() ? spanContext.getTraceId() : 
null;
+ *     // Send metrics to external system with trace correlation
+ *   }
+ * }
+ * }</pre>
+ *
+ * @see DefaultMetricsReporter
+ * @see MetricsReportingConfiguration
+ */
 public interface PolarisMetricsReporter {
-  public void reportMetric(String catalogName, TableIdentifier table, 
MetricsReport metricsReport);
+
+  /**
+   * Reports an Iceberg metrics report for a specific table.
+   *
+   * @param catalogName the name of the catalog containing the table
+   * @param table the identifier of the table the metrics are for
+   * @param metricsReport the Iceberg metrics report (e.g., {@link
+   *     org.apache.iceberg.metrics.ScanReport} or {@link 
org.apache.iceberg.metrics.CommitReport})
+   * @param receivedTimestamp the timestamp when the metrics were received by 
Polaris
+   */
+  void reportMetric(
+      String catalogName,
+      TableIdentifier table,
+      MetricsReport metricsReport,
+      Instant receivedTimestamp);
+
+  /**
+   * Reports an Iceberg metrics report for a specific table.
+   *
+   * @param catalogName the name of the catalog containing the table
+   * @param table the identifier of the table the metrics are for
+   * @param metricsReport the Iceberg metrics report
+   * @deprecated Use {@link #reportMetric(String, TableIdentifier, 
MetricsReport, Instant)} instead.
+   *     This method is provided for backward compatibility and will be 
removed in a future release.
+   */
+  @Deprecated
+  default void reportMetric(
+      String catalogName, TableIdentifier table, MetricsReport metricsReport) {
+    reportMetric(catalogName, table, metricsReport, Instant.now());
+  }

Review Comment:
   Removed it.



##########
runtime/service/src/main/java/org/apache/polaris/service/reporting/PolarisMetricsReporter.java:
##########
@@ -18,9 +18,84 @@
  */
 package org.apache.polaris.service.reporting;
 
+import java.time.Instant;
 import org.apache.iceberg.catalog.TableIdentifier;
 import org.apache.iceberg.metrics.MetricsReport;
 
+/**
+ * SPI interface for reporting Iceberg metrics received by Polaris.
+ *
+ * <p>Implementations can be used to send metrics to external systems for 
analysis and monitoring.
+ * Custom implementations must be annotated with {@link
+ * jakarta.enterprise.context.ApplicationScoped @ApplicationScoped} and {@link

Review Comment:
   Updated the documentation.



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