OTel client spans: add `server.address` (and other semconv client attributes) so tool calls can be attributed to a server
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- python
- Lĩnh vực
- observability
Hướng nghiên cứu
Start with src/mcp/shared/jsonrpc_dispatcher.py and read the TODO about moving span creation into outbound middleware, then review linked issue #3715 for the proposed client request seam. The issue describes several possible approaches, so first determine where transport metadata can be exposed to the client span. Done means client spans include server identity and relevant MCP transport attributes, with coverage for supported transports.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
The MCP send <method> [<target>] CLIENT span created in JSONRPCDispatcher.send_raw_request only carries mcp.method.name and jsonrpc.request.id:
# src/mcp/shared/jsonrpc_dispatcher.py (v2.3.0 / main)
with otel_span(
span_name,
kind=SpanKind.CLIENT,
attributes={"mcp.method.name": method, "jsonrpc.request.id": str(request_id)},
) as span:
A client connected to several MCP servers therefore can't tell from its own telemetry which server a call went to. The span name includes the tool name, but tool names aren't unique across servers, and when the server doesn't emit traces (third-party hosted servers, servers without OTel) the client span is the only record of the call.
Use case. I run Open WebUI with three MCP servers (a Playwright-based fetch server, a smart-home server, and a hosted third-party server). Tempo's span-metrics processor turns the MCP send tools/call <tool> spans into per-tool call counts and latency in Grafana. I'd like to group/filter those by server, but the only option today is guessing from tool-name patterns. Only one of the three servers emits its own SERVER spans, so following child spans doesn't help for the others.
What the semantic conventions say. The GenAI MCP semantic conventions define these on MCP client spans, none of which are currently set:
server.address/server.port(Recommended; for client spans, the address of the server behind any intermediaries, if known)network.transport(Recommended;tcpfor HTTP,pipefor stdio),network.protocol.name/network.protocol.version(Recommendedwhere applicable)mcp.session.id,mcp.protocol.version(Recommended)gen_ai.tool.name(Conditionally Requiredwhen the operation relates to a specific tool, i.e. everytools/call) andgen_ai.operation.name(Recommended). Both were added to the server-sideOpenTelemetryMiddlewarein #2970 but are still missing on the client span.
server.address / server.port are the important ones here: with them, a span-metrics or service-graph processor can break tool calls down by server with no client-side changes.
Implementation note. I realise the dispatcher is transport-agnostic and doesn't know the URL. The TODO right there (move the otel span + inject into an outbound middleware once that seam exists) and #3715 point in the same direction. Some options:
- The transport could expose connection metadata (address, port, transport kind) to the session/dispatcher when it's created, and the dispatcher adds it to every outbound span. For Streamable HTTP this comes from the URL; for stdio,
server.addressdoesn't apply butnetwork.transport=pipe(and perhaps the command name) does. - Or this lands as part of the client-side outbound seam proposed in #3715.
A smaller stopgap that would also help: an optional, user-supplied set of extra span attributes on Client / ClientSession (e.g. Client(..., otel_attributes={"server.address": ...})), so applications like Open WebUI can tag spans with the connection they already know about.
References
- GenAI MCP semantic conventions, client span attributes: https://github.com/open-telemetry/semantic-conventions-genai/blob/main/docs/gen-ai/mcp.md
- #2387: open PR adding
rpc.*,mcp.resource.uri,mcp.session.idto client/server spans (related, but no server identity) - #2970: merged, GenAI semconv attributes on the server-side middleware only
- #3715: client outbound request seam, the natural home for transport-aware span enrichment
- #1233: middleware support
- Ngôn ngữ chính
- Python
- Star
- 25k
- Fork
- 4.2k
- Merge trung bình
- 10 phút
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của modelcontextprotocol/python-sdk
-
v2
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 86/100
modelcontextprotocol/python-sdk#3978 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Client serves cached tools after its context exits with an exceptionCó thể đã có người làm @jonxsong đã nhận 1 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
modelcontextprotocol/python-sdk#3968 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
modelcontextprotocol/python-sdk#3957 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
v2
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 91/100
modelcontextprotocol/python-sdk#3934 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug v1
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
modelcontextprotocol/python-sdk#3929 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của modelcontextprotocol/python-sdk
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
521xueweihan/HelloGitHub#4729 ·
-
Relatório de erro do LinuxToysĐang mởauto-reported bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
cliproxy-quota: a tab around a credential email skips own-accounts and paced-accounts matchingĐang mởneeds-triage type:bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
pollen-robotics/reachy_mini_conversation_app#631 ·
Maintainer thường phản hồi trong vòng 7 ngày
-
stix-atlas.json: the same relationship id is used for several different mitigates relationshipsĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100