mirror of
https://github.com/PrefectHQ/fastmcp.git
synced 2026-08-24 14:34:17 +02:00
Select FastMCP client span by component key in session-id telemetry tests (SDK v2)
This commit is contained in:
parent
47e8eec026
commit
e1f3f1ca3b
1 changed files with 7 additions and 2 deletions
|
|
@ -571,13 +571,16 @@ class TestSessionIdOnSpans:
|
|||
|
||||
spans = trace_exporter.get_finished_spans()
|
||||
|
||||
# Find client-side span
|
||||
# Find the FastMCP client-side span. SDK v2 emits its own native OTel
|
||||
# spans (also lacking `fastmcp.server.name`), so select on the
|
||||
# `fastmcp.component.key` attribute that only our client_span sets.
|
||||
client_span = next(
|
||||
(
|
||||
s
|
||||
for s in spans
|
||||
if s.name == "tools/call echo"
|
||||
and s.attributes is not None
|
||||
and "fastmcp.component.key" in s.attributes
|
||||
and "fastmcp.server.name" not in s.attributes
|
||||
),
|
||||
None,
|
||||
|
|
@ -635,13 +638,15 @@ class TestSessionIdOnSpans:
|
|||
|
||||
spans = trace_exporter.get_finished_spans()
|
||||
|
||||
# Find both spans
|
||||
# Find both spans. Select the FastMCP client span on
|
||||
# `fastmcp.component.key` to avoid matching SDK v2's native OTel span.
|
||||
client_span = next(
|
||||
(
|
||||
s
|
||||
for s in spans
|
||||
if s.name == "tools/call echo"
|
||||
and s.attributes is not None
|
||||
and "fastmcp.component.key" in s.attributes
|
||||
and "fastmcp.server.name" not in s.attributes
|
||||
),
|
||||
None,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue