Repository navigation
[Feature]: Export existing request telemetry through an opt-in metadata-only scrape endpoint #5117
Description
Area
Multiple areas
What are you trying to accomplish?
Integrate existing logical-request, physical-send, terminal and latency facts with operator monitoring without reading raw request history or exporting private identifiers.
What prevents this today?
src/usage/log.ts:274 already stores bounded operational facts, and src/server/management/routing-analytics-routes.ts:24 serves JSON analytics. The pinned tree has no standard scrape exporter. The gap is export format and bounded aggregation, not absent observability.
What should OpenCodex do?
Add an opt-in management-plane text exposition endpoint with documented counter/histogram lifecycle. Reuse existing completion/attempt facts, keep labels closed and bounded, and preserve independent management authentication.
Example usage or interface
An operator scrapes aggregate logical requests, physical sends, terminal outcome counts, duration and TTFT. Protocol/result/recovery class may be labels; request/key/account/model IDs, raw errors, prompts and tool bodies never are. Metric names and route are design proposals.
Alternatives or workarounds
Existing JSON analytics remains valid for interactive use. Raw request labels or scraping historical logs on every poll would make cardinality and cost unbounded. New timing instrumentation is outside this issue.
Additional context
Source snapshot: 7864869c31c41cca9830d93540238f17df8faafb after fast-forwarding dev on 2026-09-19. This is source-grounded analysis, not a runtime test result.
Closed #1217 owns durable stream-stage attribution and is not reopened. This proposal exports existing facts only; standard GenAI field mapping is deferred until verified.
Implementation path
- Add
src/server/metrics-registry.tswith bounded in-memory counters/histograms and explicit restart semantics. - Feed it from existing lifecycle/completion/attempt seams in
src/server/request-log.ts; avoid rescanning logs on scrape. Define incomplete/aborted and missing-TTFT denominators. - Add management route in
src/server/management/metrics-routes.tsand register it inroute-registry.ts. - Wire opt-in config type, validation/defaults, persistence/hydration and startup consumers; default remains off.
- Add
tests/server/management-metrics-export.test.ts; update management/config structure owners anddocs-site/src/content/docs/reference/management-api.md.
Acceptance criteria and verification
- One logical request with retries increments logical count once and physical sends by actual sends.
- HTTP 200 with failed terminal event is not counted as successful completion.
- Management credential required; data credentials do not grant access.
- Canary private strings and arbitrary IDs never appear in output; label series stay bounded.
- Disabled mode adds no exporter timer/network activity; restart/reset semantics and units are documented.
Register new tests in both layout inventories, preserve size caps, and update the existing structure owners. User-facing policy changes need corresponding public documentation and non-contradictory translations. Run focused tests and exact-head hosted CI during implementation; no local suite was run for this analysis.
Checks
- I searched existing issues and documentation.
- This request describes a concrete OpenCodex workflow rather than merely naming a desired technology.
- I removed secrets and personal data.
Activity
test(server): fix the real-flow fixtures and the WebSocket wiring oracle
fix(server): finalize failed pre-response reads before rethrow
fix(server): classify pre-response client aborts as client_cancel
test(server): make the abort fixture observe the real outgoing signal
feat(server): add the test-only finalized-row observer seam
test(server): deterministic error-boundary and rejection-safe waits
test(server): make the SSE cancellation mock observe the abort signal
fix(server): classify successful 101 upgrades as completed
test(server): activate the live upgrade fixture through the real elig…
fix(server): finalize live-sideband exits and harden the upgrade fixture
test(server): cover acquisition cancellation, deadline, and refusal p…
test(providers): add fixed-phase timing diagnostics to the CodeBuddy …
test(server): isolate acquisition fixtures with immediate try/finally
feat(server): opt-in bounded metrics export endpoint
2 remaining items
fix(server): finalize failed pre-response reads before rethrow
fix(server): classify pre-response client aborts as client_cancel
test(server): make the abort fixture observe the real outgoing signal
feat(server): add the test-only finalized-row observer seam
test(server): deterministic error-boundary and rejection-safe waits
test(server): make the SSE cancellation mock observe the abort signal
fix(server): classify successful 101 upgrades as completed
test(server): activate the live upgrade fixture through the real elig…
fix(server): finalize live-sideband exits and harden the upgrade fixture
test(server): cover acquisition cancellation, deadline, and refusal p…
test(providers): add fixed-phase timing diagnostics to the CodeBuddy …
test(server): isolate acquisition fixtures with immediate try/finally
Export bounded request metrics through an opt-in scrape endpoint (#5183)
lidge-jun commentedon Sep 19, 2026
Resolved on dev by #5183, merge fec3add. Full acceptance was reviewed against the opt-in authenticated exporter, bounded/private-data-free series, logical versus physical send accounting, terminal and cancellation semantics, and documented reset/units. Exact-head hosted run35464220426 passed all applicable jobs at 4d9bcea; merge ancestry on dev is verified. Local execution was not used.