dimas-b commented on code in PR #3385:
URL: https://github.com/apache/polaris/pull/3385#discussion_r2835636173


##########
polaris-core/src/main/java/org/apache/polaris/core/persistence/metrics/MetricsRecordIdentity.java:
##########
@@ -92,4 +93,45 @@ public interface MetricsRecordIdentity {
    * store and index specific metadata fields as needed.
    */
   Map<String, String> metadata();
+
+  // === Request Context Fields ===
+
+  /**
+   * Name of the principal (user) who made the request.
+   *
+   * <p>This is the authenticated principal name from the security context 
when the metrics report
+   * was received. Useful for auditing and tracking which users are accessing 
which tables.
+   */
+  Optional<String> principalName();
+
+  /**
+   * Server-generated request ID for correlation.
+   *
+   * <p>This is the request ID assigned by the Polaris server when the metrics 
report was received.
+   * It can be used to correlate metrics with server logs and other telemetry.
+   */
+  Optional<String> requestId();
+
+  /**
+   * OpenTelemetry trace ID.
+   *
+   * <p>The trace ID from the OpenTelemetry context when the metrics report 
was received. This
+   * enables correlation with distributed traces across services.
+   */
+  Optional<String> otelTraceId();

Review Comment:
   This elevates OTel Trace ID and other (new) properties here to the Metrics 
SPI level (by virtue of being a parameter to 
`MetricsPersistence.writeScanReport()`, etc..
   
   This idea does not sit well with me. I believe the SPI surface should not 
contain OTel concepts. OTel is a "cross-cutting concern". Similarly, storing 
Principal name with records is fine, but I do not think it should be part of 
the SPI.
   
   I believe the implementation (e.g. `JdbcMetricsPersistence`) should obtain 
OTel, Principal and other data from request-scoped objects in implementations 
method (below the SPI surface). We can certainly keep the code that obtains 
this information open for sharing across different implementations, if needed.
   
   WDYT? (I believe we discussed it before, but it's probably lost in the vast 
pile of comments 😅 )



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