Skip to content

Report every finished request to an optional observer - #10

Merged
ewanc26 merged 1 commit into
mainfrom
feat/request-observer
Jul 28, 2026
Merged

Report every finished request to an optional observer#10
ewanc26 merged 1 commit into
mainfrom
feat/request-observer

Conversation

@ewanc26

@ewanc26 ewanc26 commented Jul 27, 2026

Copy link
Copy Markdown
Owner

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:

  • runs before the status is decided, so it can attribute no status to
    anything,
  • never runs at all for a plain HTTP route, and
  • never runs for a request the rate limiter refused.

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_observer is called once per request from every
path 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_OBSERVER lets a consumer build against a Wolfram with or
without the observer rather than forcing a lockstep upgrade.

Verification

137/137 ctest, including a new xrpc_server_observer case that covers each
of 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

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
ewanc26 marked this pull request as ready for review July 28, 2026 08:55
@ewanc26
ewanc26 merged commit 0a7b051 into main Jul 28, 2026
3 checks passed
@ewanc26
ewanc26 deleted the feat/request-observer branch July 28, 2026 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant