Repository navigation
feat(serving): API-usage + session analytics behind ControlPlaneStore (ADR 0010 slice 4) - #134
Merged
Merged
Conversation
… (ADR 0010 slice 4) api_usage/api_sessions never shared query_engine._conn (AuthManager.db_path is always its own file), so EmbeddedControlPlaneStore gains a second, orthogonal usage_db_path_provider alongside conn_provider. Scope widened past usage_table.py/analytics.py: key_rotation.py's old-key-usage queries and admin_ui.py's QPS tile also queried these tables directly and are covered here too, so slice 5's PostgreSQL swap doesn't leave two call sites hard-wired to a local DuckDB file. All pre-port public/test-facing signatures preserved.
DORA Metrics
|
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
api_usage(per-tenant/per-key request counters) andapi_sessions(per-request latency/entity/query telemetry) move behindControlPlaneStore.query_engine._conn—AuthManager.db_pathalways resolves to its own DuckDB file.EmbeddedControlPlaneStoregains a second, orthogonalusage_db_path_provideralongsideconn_provider/alert_rules_path_provider;AuthManagerbuilds a private embedded store around its own path (mirrorsOutboxProcessor's additive-storepattern) rather than sharing the app-wide store.usage_table.py+analytics.py:KeyRotator(key_rotation.py) queriedapi_usagedirectly for old-key-usage stats, and the admin dashboard (admin_ui.py) queriedapi_sessionsdirectly for its QPS tile — both bypassed every prior slice's port. Covered here so slice 5's PostgreSQL swap doesn't leave two call sites hard-wired to a local DuckDB file.ensure_usage_table(manager),record_usage(manager, tenant_key, endpoint),usage_by_tenant(manager), the 5 analytics read functions takingdb_path,_insert_session(db_path, request_id, record)) — only the SQL/connection handling moved intoEmbeddedControlPlaneStore.record_usage's temp-path rename onduckdb.IOException) and the best-effort log-and-return-on-exhaustion behavior for session writes (vs.record_api_usage's raise, whichrecord_usagedepends on to skip its post-insert audit publish) both moved verbatim.Test plan
ruff check/ruff format --checkclean onsrc+testsmypy src— no issues (114 files)🤖 Generated with Claude Code