-
[OPIK-7051] [BE] feat: lift per-workspace observability to BaseRedisSubscriber (#7258)
发布于
2026-06-29 09:59:19 +00:00 - [OPIK-7051] [BE] feat: lift per-workspace observability to BaseRedisSubscriber
Follow-up to #7195. Generalizes the workspace/user attribution built there for
online-scoring so every Redis stream subscriber gets it, and replaces the
online-only processed counter with a workspace dimension on the existing base
processing-time histogram.- Rename WorkspaceScopedMessage -> RedisSubscriberMessage and make it the common
type for all subscriber messages (userName()/workspaceName() now have defaults).
All 12 message types implement it (webhook, dataset-export, experiment-aggregates,
experiment-item, closing-trace-thread, agent-insights, the 6 ToScore records). - BaseRedisSubscriber.messageContext() default now derives workspace/user from the
message via RedisSubscriberMessage, so the 5 hand-rolled subscriber overrides are
removed and AgentInsightsReport (which had none) gains real workspace_id. - Tag the base processing_time histogram with workspace_id/workspace_name; this
gives per-workspace throughput (histogram_count) AND latency, making the
online_scoring_processed_total counter from #7195 redundant -> removed.
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com
- [OPIK-7051] [BE] feat: carry workspaceName on span/thread online-scoring messages
Guarantees the per-workspace metrics get a real workspace name (not the id
fallback) on every online-scoring message where the name is available, without
any remote call or new persistence:- SpanToScore*/TraceThreadToScore* records gain a nullable workspaceName field;
all six ToScore records implement a withWorkspaceName copy-method (default
no-op on the RedisSubscriberMessage interface). - OnlineScorePublisher.enqueueMessage stamps the workspaceName resolved from the
reactive context onto messages that don't already carry one (and reuses it for
the enqueue metric). Context-less producers (the closing-thread job) have no
name to stamp, so those messages keep falling back to the workspace id. - OnlineScoringSpanSampler sets workspaceName directly from SpansCreated (the
event already carries it), guaranteeing the automatic span path.
Traces were already covered (TraceService populates the event name; the sampler
copies it onto the message), so no trace-path change is needed.Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com
- [OPIK-7051] [BE] fix: consistent workspace id/name fallback in messageContext
BaseRedisSubscriber.messageContext normalizes the workspace id once and reuses it as the
workspaceName fallback, so a blank message workspace id yields matching id/name tags
instead of workspace_id="unknown" with a blank workspace_name.Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com
- [OPIK-7051] [BE] refactor: keep auth dependency out of the RedisSubscriberMessage marker
Addresses review: the api-layer RedisSubscriberMessage marker no longer references
RequestContext. userName() now defaults to null for system-initiated streams, and
BaseRedisSubscriber.messageContext applies the RequestContext.SYSTEM_USER fallback (single
source of truth, not a duplicated literal), so domain message types implementing the
marker don't inherit an auth-layer dependency.Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com
Co-authored-by: Claude Opus 4.8 (1M context) noreply@anthropic.com
下载附件