fix(telemetry): include client_info in initialize response event metadata - #248
Conversation
…data
The [:anubis_mcp, :server, :response] event fired on a successful
initialize carries only %{method: "initialize", status: :success} —
client_info is already parsed and bound in scope at that exact call
site (used moments earlier for the initializing log event and to
build session state) but never included in the telemetry metadata.
This makes it impossible for a telemetry handler to know which client
(name/version) connected without re-deriving it from logs or session
state separately. Add client_info to the existing metadata map — no
new event, no API changes, purely additive.
Added a regression test attaching to the real response event and
asserting client_info flows through end-to-end via the actual
initialize request path.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughProblem
SolutionExtend the existing RationaleImproves observability of which client is interacting with the server without changing event shape/signatures beyond adding WalkthroughThe session’s successful Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: f69e2f47-fcec-426b-a38b-f2cf95a4f1dc
📒 Files selected for processing (2)
lib/anubis/server/session.extest/anubis/server/session_test.exs
…hard-coded event path Addresses CodeRabbit review comment on PR zoedsoupe#248 - keeps the test aligned with the production event definition instead of duplicating the literal event path.
🚀 Want to release this? --- ## [1.11.0](v1.10.0...v1.11.0) (2026-07-29) ### Features * **session_store:** supervise Redis store subtree to make restarts race-free ([#242](#242)) ([48c8c1a](48c8c1a)) ### Bug Fixes * **prompts:** wrap prompt content objects and map system_message to user role ([#234](#234)) ([2451bb7](2451bb7)) * **server:** make title option compile in use Anubis.Server.Component ([b04feed](b04feed)) * **server:** use restart :temporary for session processes ([#240](#240)) ([30bc4f5](30bc4f5)) * **sse:** buffer partial events across Finch chunks ([#245](#245)) ([beea2f6](beea2f6)) * Stream the client SSE GET instead of buffering it (server push never delivered) ([#231](#231)) ([a722c1b](a722c1b)) * **telemetry:** expose tool call success/failure in tool_call span metadata ([#246](#246)) ([ace5ecb](ace5ecb)) * **telemetry:** include client_info in initialize response event metadata ([#248](#248)) ([74ed457](74ed457)) * **telemetry:** namespace tool_call span under :anubis_mcp ([#244](#244)) ([561a96b](561a96b)) ### Tests * **server:** fix stale tool_call event name and function_exported? loading races ([7247d2c](7247d2c)) * **transport:** synchronize held SSE plug with Bypass teardown ([93c5a34](93c5a34)) ### Continuous Integration * fix dialyzer plt caching ([8424439](8424439)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Problem
The
[:anubis_mcp, :server, :response]telemetry event fired after a successfulinitializerequest only carries%{method: "initialize", status: :success}as metadata.client_info(the client's self-reportedname/versionfrom the MCP handshake) is already parsed and bound in scope at that exact call site — it's used moments earlier to build session state and to log an"initializing"event — but it never makes it into the telemetry metadata.This makes it impossible for a telemetry handler to know which client connected (by name/version) without separately re-deriving it from logs or session state. For anyone building observability on top of Anubis (e.g. tracking which integrations/agents are using a given MCP server), this is a real gap:
initializeis the one point in the protocol where the client actively identifies itself, and that identity is silently dropped before telemetry ever sees it.Solution
Add
client_info: client_infoto the existing metadata map passed toTelemetry.execute/3in theinitializehandler. No new event, no signature changes, no behavior changes to anything else — purely additive metadata on an event that already fires.Added a regression test that attaches directly to
[:anubis_mcp, :server, :response], drives a realinitializerequest through a session, and assertsclient_infoflows through end-to-end (not just a unit-level check on the call site).Rationale
This is the smallest possible fix: the value was already computed and in scope, so this is a one-line addition to a map literal, no new computation, no new event. I scoped it strictly to the
initializeresponse event rather than also touching the async-dispatchdecode_task_result/3clauses (which fire this same event for every subsequent request) — those clauses only haveinflight/statein scope, and whilestate.client_infois available there too, doing so would widen this PR beyond a single, easily-reviewable change. Happy to follow up with a second PR extending this to per-request events if that's wanted, but felt out of scope for the initial connection-identity gap this PR closes.