fix(observe): serve the off-path pool's counters at /stats - #50
Merged
Conversation
modes.Pool tracked queued/pending/processed/dropped/errors correctly and nothing ever read them: metrics.Snapshot had no field and the /stats handler never called Stats(). So docs/how-to/operating-modes.md instructed operators to watch dropped and errors -- and made a point of contrasting that with a dashboard which reports only queue depth -- while describing a counter no consumer could reach. dropped is the one that changes a reader's conclusion. A drop is an observation silently given up, so a rising dropped means the potential_*/projected_* figures UNDERSTATE what compaction would have saved. Reporting depth while hiding drops is precisely the gap the doc calls out elsewhere. Exposed as observe_queue, omitted when no pool is running so a sync-only deployment shows no phantom queue. metrics declares its own QueueStats rather than importing modes, because the dependency runs the other way. Purely additive: no existing /stats key renamed or removed, so deploy/harbor/*.py keeps parsing. Found by a docs audit that diffed every documented field against the Snapshot struct -- the kind of gap neither a code review nor a docs review finds alone, since each half was individually correct. The test asserts the counters arrive over HTTP, not that the pool counts; it fails without the wiring with the field absent. Signed-off-by: Osher-Elhadad <Osher.Elhadad@ibm.com>
This was referenced Aug 10, 2026
Merged
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.
Found by the docs audit in #49, which diffed every documented
/statsfield against the actualSnapshotstruct.Problem
modes.Pooltrackedqueued/pending/processed/dropped/errorscorrectly — and nothing ever read them.metrics.Snapshothad no field for them andproxy.Handler.statsnever calledStats().Meanwhile
docs/how-to/operating-modes.md(added by #43) instructs operators to watchdroppedanderrors, and makes a point of contrasting that with a dashboard which reports only queue depth. The doc described a counter no consumer could reach.Both halves were individually correct, which is why neither the code review nor the docs review caught it — the gap only exists between them.
Why
droppedin particular mattersA drop is an observation silently given up. So a rising
droppedmeans thepotential_*/projected_*figures understate what compaction would have saved. Serving queue depth while hiding drops is exactly the failure the doc calls out in the competitor's dashboard.Fix
Exposed as
observe_queue, filled by the host at serve time (the pool lives inmodes, which sits abovemetrics, sometricscannot read it).omitempty, so a sync-only deployment shows no phantom queue.metricsdeclares its ownQueueStatsrather than importingmodes— the dependency runs the other way and importing it would invert the layering.Purely additive: no existing
/statskey renamed or removed, sodeploy/harbor/*.pykeeps parsing.Test
TestObserveQueueCountersReachStatsasserts the counters arrive over HTTP — it tests the wiring, not the pool, which already had coverage.Verified non-vacuous. With the wiring removed:
Gates
go build -tags cg_skeleton ./...·go test -tags cg_skeleton ./...·go test -race ./proxy/... ./metrics/...·gofmt -l·go vet— all clean.