-
[OPIK-6938] [BE] feat: add error count by error type metric (#7112)
发布于
2026-06-17 13:00:15 +00:00 - [OPIK-6938] [BE] feat: add error count by error type metric
Emit opik.errors.count for 5XX server errors, tagged with the root-cause
exception class name, matched-route endpoint, and workspace id/name.- OpikGenericExceptionMapper: catch-all for uncaught 5XX, extends Dropwizard
LoggingExceptionMapper so logging and 500 rendering are unchanged. - OpikWebApplicationExceptionMapper: records 5XX WebApplicationExceptions
(e.g. InternalServerErrorException), returns the original response; 4XX ignored. - ErrorMetrics/ErrorMetricsResolver: OTel counter + label resolution.
-
refactor(metrics): replace inline qualified names with imports
-
feat(metrics): break down async-path errors by error_type
- BaseRedisSubscriber: tag processing_errors and unexpected_errors counters
with error_type (root-cause exception class name). - EventInterceptor: collapse the per-listener name-embedded metric into a
single opik.event.error counter with listener + error_type labels, built once.
- feat(metrics): attribute redis subscriber processing errors to workspace_id + user_name
Adds a subclass-provided messageContext() hook (mirroring the workspace/user
that processEvent already sets into the Reactor context) threaded through
ProcessingResult, so processing_errors is tagged with error_type + workspace_id- user_name. workspace_name is not carried into async messages, so it is omitted.
Overridden in the dataset-export, experiment-aggregates, experiment-item,
webhook and closing-trace-thread subscribers; others fall back to unknown.
- feat(metrics): propagate workspace_name to redis subscriber error metrics
Adds workspace_name to the redis processing_errors counter. RequestContext.workspaceName
(set at auth) flows via the Reactor context into the request-originated producers
(experiment execution, dataset export) and into the message payload; WebhookEvent already
carries it. ExperimentAggregation and ClosingTraceThread messages have no name source
(redis bucket / ClickHouse row) so they fall back to unknown. New message field is nullable
for rolling-deploy compatibility with the Java stream codec.-
fix(metrics): preserve error response body in web application exception mapper
-
refactor(metrics): split ErrorMetrics into HttpErrorMetrics and ErrorMetricsResolver
-
fix(redis): ignore unknown properties in stream codec for rolling-upgrade compatibility
-
test(redis): guard stream codec against reintroducing FAIL_ON_UNKNOWN_PROPERTIES
-
refactor(metrics): resolve message context lazily and init event error counter eagerly
-
refactor(metrics): hoist metric label AttributeKeys to shared constants
下载附件