Expose hosted-proxy store size and flush-duration metrics#468
Merged
Conversation
alistair3149
force-pushed
the
metrics-proxy-store-gauges
branch
2 times, most recently
from
July 23, 2026 04:55
bc862ba to
e54fa31
Compare
…rics The proxy's upstream-token map grows with cumulative sign-ins and is never swept, and every token write flushes the whole store synchronously (serialize + encrypt + write). Neither the growth, the per-refresh flush cost, nor a failing flush had any operator signal. Add four Prometheus series on /metrics (when MCP_METRICS=true): - mcp_proxy_store_upstream_tokens (gauge) and mcp_proxy_store_clients (gauge), read on scrape via a stats provider wired in buildApp, mirroring the existing mcp_active_sessions gauge. Backed by a new ProxyStore.stats(). - mcp_proxy_store_flush_duration_seconds (histogram), observed in the persistence store's flushSync with finer sub-millisecond buckets. Successful flushes only. - mcp_proxy_store_flush_failures_total (counter), incremented in flushSync's catch so a slow-and-failing flush is visible to /metrics, not only in the onError log. A failed flush leaves the latest sign-in change in memory only, so it is the signal an operator alerts on. These are the gate for deciding whether the token-map eviction sweep and per-row persistence are worth building; instrument before engineering. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
alistair3149
force-pushed
the
metrics-proxy-store-gauges
branch
from
July 23, 2026 04:57
e54fa31 to
697b46f
Compare
alistair3149
marked this pull request as ready for review
July 23, 2026 04:58
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
The hosted OAuth proxy's upstream-token map grows with cumulative sign-ins and is never swept, and every token write flushes the whole store synchronously (serialize + AES-GCM encrypt + write). Today there is no operator signal for either — you cannot tell whether the map's memory or the per-refresh flush cost is becoming a problem. This adds that signal.
What changed
Three Prometheus series on
/metrics(whenMCP_METRICS=true):mcp_proxy_store_upstream_tokens(gauge) — the unbounded set; grows with cumulative sign-ins.mcp_proxy_store_clients(gauge) — FIFO-capped registered clients.mcp_proxy_store_flush_duration_seconds(histogram) — durable-flush latency, with finer sub-millisecond buckets than the tool-call histogram.The gauges are read on scrape via a stats provider wired in
buildApp, mirroring the existingmcp_active_sessionspattern; backed by a newProxyStore.stats(). The histogram is observed in the persistence store'sflushSync.Testing
stats(), the flush histogram, and the lazy-provider gauges (including the zero-default and disabled-recorder no-op paths); an integration test that a durable write records a flush duration end-to-end.tsc,oxlint,oxfmtclean.MCP_METRICS=true: all three series are exposed on/metrics.docs/operations.md"Exposed series" list and a CHANGELOG entry updated.🤖 Generated with Claude Code