Skip to content

fix(telemetry): added mcp tracing context propagation #569

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 5, 2025

Conversation

poshinchen
Copy link
Contributor

Description

Add mechanism to attach otel context into mcp _meta and pass along to the tools.

Before the change: https://us.cloud.langfuse.com/project/cmbb4s57d01xiad07eex8qvrl/traces/00d374af585c0dd249e80c8d63a82626?timestamp=2025-07-26T21:57:45.354Z&display=details

After the change: https://us.cloud.langfuse.com/project/cmbb4s57d01xiad07eex8qvrl/traces/1cf20ee13a25b952f55196269190b417?timestamp=2025-07-29T18:01:04.292Z&display=details

Related Issues

https://github.com/strands-agents/private-sdk-python-staging/issues/126

Documentation PR

N/A

Type of Change

Bug fix

Testing

How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli

  • I ran hatch run prepare

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@jer96
Copy link
Member

jer96 commented Jul 31, 2025

hi @poshinchen after taking a look at modelcontextprotocol/modelcontextprotocol#246, i'm having a bit of trouble understanding exactly what this PR is doing. many of the implementations that were linked to the MCP issue seem to be much simpler:

based on my understanding there are two main features

  1. trace context is propagated from client -> server. it seems like this is handled by updating the _meta field with the necessary context
  2. emitting spans for MCP client invocations for Strands agents. the implementation here feels like it would be akin to the other manual instrumentation we already do in Strands for things like model invocations and standard tool calls.

can you help shed some light on the added complexity in this PR?

@dbschmigelski dbschmigelski changed the title Fix/mcp tracing fix(telemetry): added mcp tracing context propagation Aug 5, 2025
@poshinchen poshinchen merged commit 34d499a into strands-agents:main Aug 5, 2025
12 checks passed
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.

4 participants