Report every finished request to an optional observer - #10
Merged
Conversation
Nothing in the server saw a request together with its outcome. The auth callback is the closest thing, and it runs before the status is decided, never runs at all for a plain HTTP route, and never runs for a request the rate limiter refused — so a consumer counting requests there is counting a subset it cannot name and attributing no status to any of it. Called once per request from every path that decides a status, the limiter's 429 included, on the worker thread serving the connection: it is for incrementing a counter, not for writing to a socket. WF_XRPC_HAS_REQUEST_OBSERVER lets a consumer build against a Wolfram with or without it rather than requiring a lockstep upgrade.
ewanc26
marked this pull request as ready for review
July 28, 2026 08:55
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.
Needed by MetalBear, which wants per-endpoint and per-status request metrics
and currently cannot get them from anything the server exposes.
Nothing in the server sees a request together with its outcome. The auth
callback is the closest thing, and it:
anything,
A consumer counting requests there is counting a subset it cannot name. The
429 case is the sharpest: a refusal the operator never sees counted is exactly
the one they most need to see.
wf_xrpc_server_set_request_observeris called once per request from everypath that decides a status, on the worker thread serving the connection — it
is for incrementing a counter, not for writing to a socket, and the header
says so.
WF_XRPC_HAS_REQUEST_OBSERVERlets a consumer build against a Wolfram with orwithout the observer rather than forcing a lockstep upgrade.
Verification
137/137
ctest, including a newxrpc_server_observercase that covers eachof the three blind spots above — a handler's own non-200 status, an
auth-refused route, a plain HTTP route, an unregistered method, and clearing
the observer back to NULL.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Lahd4tPa1cWFhQB4YXPvwH