Skip to content

OpenTelemetry integration out of the box #1264

Open

Description

@felixweinberger

Provide OpenTelemetry (@opentelemetry/api) capabilities out of the box - allow users to inject their own telemetry Tracer/Metrics Provider.

Part of v2 SDK work.

Activity

  1. added
    v2Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes
    P2Moderate issues affecting some users, edge cases, potentially valuable feature
    on Dec 8, 2025
  2. added
    enhancementRequest for a new feature that's not currently supported
    ready for workEnough information for someone to start working on
    on Dec 16, 2025
  3. ghost removed
    P2Moderate issues affecting some users, edge cases, potentially valuable feature
    on Apr 16, 2026
  4. ghost added
    P3Nice to haves, rare edge cases
    on Apr 16, 2026
  5. Necmttn commented on Jun 21, 2026

    @Necmttn

    For the TypeScript SDK, I would start with instrumentation hooks rather than a vendor opinion.

    Accept a tracer/meter provider or a small lifecycle subscriber, then emit boundaries for client request, server request, tools/call, resources/read, prompts, and notifications. Each event/span needs session id, request id, method, tool/resource name when present, and trace context from MCP metadata.

    That gives OpenTelemetry users first-class spans, while users with their own audit layer can consume the same lifecycle without pulling an exporter into the SDK core.


    Generated with ax.

  6. selimaytac commented on Oct 18, 2026

    @selimaytac

    I needed this for a tool server that sends blockchain transactions (its spans should be children of the agent's tool call span), so I tested trace context over _meta with stdio on 1.32.1 and 2.3.1. In case it helps whoever picks this up:

    • Inject on the client and extract on the server is all it takes. With v2: propagation.inject(context.active(), meta) into each callTool's _meta, and in the handler context.with(propagation.extract(context.active(), ctx.mcpReq._meta ?? {}), fn). With that, the server's spans join the agent's trace; without it, they start their own.
    • Two stdio details that cost me spans: StdioClientTransport passes only getDefaultEnvironment() plus env to the server, so OTEL_* settings have to go into env explicitly; and close() waits 2 s before SIGTERM, so the server has to flush its exporter when stdin ends or the last spans are lost.

    The test that runs this end to end (agent and stdio server as separate processes, with and without propagation): https://github.com/selimaytac/hashspan/blob/9da1b25/integrations/test/mcp.int.test.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P3Nice to haves, rare edge casesenhancementRequest for a new feature that's not currently supportedready for workEnough information for someone to start working onv2Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions