feat(analytics): PR-A -- Usage Analytics v1 event pipeline foundation - #37
Merged
Conversation
Redis Streams consumer + aggregator for the new Usage Analytics capability (control-center-local, no separate service). No HTTP surface yet -- this PR only builds and proves the ingestion pipeline; the API layer, RBAC, and frontend follow in separate PRs. - analytics/schemas.py: normalized AnalyticsEvent contract + the mapping from omnibioai-auth's real InteractionEvent wire shape (the only producer today is RAG's /v1/query -- no workflow.*/api.* events exist anywhere in this workspace yet, confirmed by reading every producer). - analytics/consumer.py: a Redis Streams consumer-group worker mirroring omnibioai-auth/app/workers/interaction_consumer.py's proven shape (stable consumer name, own-pending crash recovery, ack-only-after- durable-write, fail-open on malformed payloads/Redis errors). Reads both interactions:events and audit:events under one consumer group in a single process. - analytics/aggregator.py: write-side (idempotent HINCRBY-based Redis aggregates, deduped on event id) + read-side (pure aggregate reads, never replays a stream). audit:events has no organization_id (confirmed by reading omnibioai-api-gateway's audit_client.py), so its counters/latency histogram are written ONLY to the platform-wide bare-date keys, never under an org_id-keyed one. - analytics/cache.py, analytics/metrics.py: Redis cache-aside helper and the 8 analytics_* observability counters (registered on the existing /metrics endpoint via prometheus_client, already a transitive dep). - New control-center-analytics-worker compose service, same image as control-center, command override only -- no new Dockerfile. 100% coverage on the new package; full existing suite (1029 tests) still green at 99.82% overall, above the 98% gate.
This was referenced Aug 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
First of four sub-PRs implementing Usage Analytics v1 (control-center-local, no separate service -- see the full task brief/plan). This PR ships only the Redis Streams ingestion pipeline: no HTTP surface yet.
analytics/schemas.py-- normalizedAnalyticsEventcontract + mapping from omnibioai-auth's realInteractionEventwire shape.analytics/consumer.py-- Redis Streams consumer-group worker, mirroringomnibioai-auth/app/workers/interaction_consumer.py's proven pattern (stable consumer identity, own-pending crash recovery, ack-only-after-durable-write). Reads bothinteractions:eventsandaudit:eventsin one process under one consumer group.analytics/aggregator.py-- idempotent write-side aggregation + stream-free read-side.audit:eventshas noorganization_id, so anything derived from it is written only to platform-wide keys, never org-scoped.analytics/cache.py,analytics/metrics.py-- cache-aside helper + the 8analytics_*observability counters on the existing/metricsendpoint.control-center-analytics-workercompose service (same image, command override only).Architecture notes (read before reviewing PR-C/D)
Two real gaps in the actual deployed platform, discovered by reading the code rather than assumed from the task brief:
/metricsendpoints exist, nothing scrapes them).interactions:eventshas exactly one real producer today (RAG's/v1/query) -- noworkflow.*/api.*events exist yet, and the event has noteam_id/duration_ms/request_id.Both are designed around explicitly, not hidden -- see the plan doc and this PR's own module docstrings.
Test plan
python -m pytest(backend): 1029 passed, 99.82% coverage (gate: 98%). Newanalyticspackage: 100% coverage.test_analytics_consumer.py.🤖 Generated with Claude Code