obelix74 commented on code in PR #3385:
URL: https://github.com/apache/polaris/pull/3385#discussion_r2835861373
##########
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:
I've addressed this by removing the OTel and request context fields from the
SPI layer.
Changes made:
- Removed `principalName()`, `requestId()`, `otelTraceId()`,
`otelSpanId()`, and `reportTraceId()` from the `MetricsRecordIdentity` interface
- Introduced a `RequestContextProvider` interface in `polaris-core` to
abstract request context access without coupling the SPI to implementation
details
- Created `ServiceRequestContextProvider` in `runtime-service` that
obtains these fields from request-scoped CDI beans (SecurityContext, RESTEasy
request context, OpenTelemetry Span)
- Updated `JdbcMetricsPersistence` to accept a `RequestContextProvider`
and obtain context fields when converting from SPI to Model objects
- The JDBC Model classes still contain these fields (as they're
implementation-specific), but they're now populated from the request context
provider rather than being passed through the SPI
--
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]