Skip to content

fix(telemetry): include client_info in initialize response event metadata - #248

Merged
zoedsoupe merged 2 commits into
zoedsoupe:mainfrom
acollado-g2:fix/initialize-telemetry-client-info
Jul 29, 2026
Merged

zoedsoupe merged 2 commits into
zoedsoupe:mainfrom
acollado-g2:fix/initialize-telemetry-client-info

Conversation

@acollado-g2

Copy link
Copy Markdown
Contributor

Problem

The [:anubis_mcp, :server, :response] telemetry event fired after a successful initialize request only carries %{method: "initialize", status: :success} as metadata. client_info (the client's self-reported name/version from 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: initialize is 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_info to the existing metadata map passed to Telemetry.execute/3 in the initialize handler. 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 real initialize request through a session, and asserts client_info flows 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 initialize response event rather than also touching the async-dispatch decode_task_result/3 clauses (which fire this same event for every subsequent request) — those clauses only have inflight/state in scope, and while state.client_info is 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.

…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.
@coderabbitai

coderabbitai Bot commented Jul 28, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 298d83c3-efef-40b0-9417-3948f6904d13

📥 Commits

Reviewing files that changed from the base of the PR and between b00c6bc and 0f6d96a.

📒 Files selected for processing (1)
  • test/anubis/server/session_test.exs

📝 Walkthrough

Problem

initialize response telemetry didn’t include the parsed client_info metadata.

Solution

Extend the existing [:anubis_mcp, :server, :response] telemetry event for initialize to propagate client_info (with the existing method and status fields) and add a regression test to verify it end-to-end.

Rationale

Improves observability of which client is interacting with the server without changing event shape/signatures beyond adding client_info, or altering runtime behavior.

Walkthrough

The session’s successful initialize response telemetry now includes the incoming client_info alongside the method and status. A new test attaches to the response telemetry event, performs initialization, and verifies all emitted metadata fields.

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: adding client_info to initialize response telemetry metadata.
Description check ✅ Passed The description follows the required Problem, Solution, and Rationale template and explains the change well.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2451bb7 and b00c6bc.

📒 Files selected for processing (2)
  • lib/anubis/server/session.ex
  • test/anubis/server/session_test.exs

Comment thread test/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.
@zoedsoupe
zoedsoupe merged commit 74ed457 into zoedsoupe:main Jul 29, 2026
21 of 24 checks passed
@zoedsoupe zoedsoupe mentioned this pull request Jul 29, 2026
zoedsoupe added a commit that referenced this pull request Jul 29, 2026
🚀 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).
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.

2 participants