-
Notifications
You must be signed in to change notification settings - Fork 167
Description
Description
I am using Logfire with Pydantic-AI and Streamable HTTP MCP servers.
I have auto-instrumentation turned on for Pydantic-AI, MCP, and HTTPX.
logfire.instrument_pydantic_ai()
logfire.instrument_mcp()
logfire.instrument_httpx()
When my agent runs and invokes a tool via MCP, I see the MCP request nested under the "agent run" span.

I also see the POST from the agent service to the MCP server with its internal spans.

However, I would expect the spans for the MCP server to be nested under the MCP request: tools/call get_recent_conversations_in_channel
span, and they are not currently correlated.
span: MCP request: tools/call get_recent_conversations_in_channel
trace_id: 0199aaac2be84786393ff770859de3c3
span_id: fd0aa8c8a61cc2f4
parent_span_id: 1c1d083ac51b2071
span: POST tiger-slack-mcp-server/mcp
trace_id: 0199aaac2be84786393ff770859de3c3
span_id: 6bd2de03f4094614
parent_span_id: 29a46c34de05d09a
It appears that the auto-instrumentation for httpx is using the span of the function in which agent.run(...)
was called, rather than the span of the MCP tool call for its parent_span_id.
Python, Logfire & OS Versions, related packages (not required)
logfire="4.10.0"
platform="macOS-15.6.1-arm64-arm-64bit-Mach-O"
python="3.13.2 (v3.13.2:4f8bb3947cf, Feb 4 2025, 11:51:10) [Clang 15.0.0 (clang-1500.3.9.4)]"
[related_packages]
requests="2.32.5"
pydantic="2.11.7"
openai="1.109.1"
protobuf="5.29.5"
rich="14.1.0"
executing="2.2.0"
opentelemetry-api="1.36.0"
opentelemetry-exporter-otlp-proto-common="1.36.0"
opentelemetry-exporter-otlp-proto-http="1.36.0"
opentelemetry-instrumentation="0.57b0"
opentelemetry-instrumentation-dbapi="0.57b0"
opentelemetry-instrumentation-httpx="0.57b0"
opentelemetry-instrumentation-psycopg="0.57b0"
opentelemetry-instrumentation-system-metrics="0.57b0"
opentelemetry-proto="1.36.0"
opentelemetry-sdk="1.36.0"
opentelemetry-semantic-conventions="0.57b0"
opentelemetry-util-http="0.57b0"