René's URL Explorer Experiment


Title: Add basic OpenTelemetry tracing for client and server requests by Kludex · Pull Request #2381 · modelcontextprotocol/python-sdk · GitHub

Open Graph Title: Add basic OpenTelemetry tracing for client and server requests by Kludex · Pull Request #2381 · modelcontextprotocol/python-sdk

X Title: Add basic OpenTelemetry tracing for client and server requests by Kludex · Pull Request #2381 · modelcontextprotocol/python-sdk

Description: Summary Adds OpenTelemetry tracing to MCP client and server request handling, with W3C trace context propagation via _meta per SEP-414. opentelemetry-api is added as a mandatory dependency. It provides a no-op tracer by default - spans are only recorded when the user configures an OTel SDK (e.g. via Logfire, Jaeger, OTLP exporters). Spans Client (send_request): MCP send tools/call my_tool with SpanKind.CLIENT Server (_handle_request): MCP handle tools/call my_tool with SpanKind.SERVER Server spans record ERROR status when the handler returns ErrorData. Client spans record errors automatically via OTel's start_as_current_span when MCPError propagates. Trace context propagation (SEP-414) On send, traceparent/tracestate are injected into _meta of the JSON-RPC request. On the server side, _meta is extracted and used as the parent context for the handler span. This enables cross-process trace propagation over stdio and HTTP transports. Attributes mcp.method.name - the JSON-RPC method (e.g. tools/call) jsonrpc.request.id - the request ID New files src/mcp/shared/_otel.py - OTel helpers (otel_span, inject_trace_context, extract_trace_context) tests/shared/test_otel.py - E2E test verifying span names, kinds, attributes, and trace propagation Test plan E2E test: client calls a tool, verifies both client and server spans with correct names, kinds, attributes, and same trace ID All existing tests pass 100% coverage

Open Graph Description: Summary Adds OpenTelemetry tracing to MCP client and server request handling, with W3C trace context propagation via _meta per SEP-414. opentelemetry-api is added as a mandatory dependency. It prov...

X Description: Summary Adds OpenTelemetry tracing to MCP client and server request handling, with W3C trace context propagation via _meta per SEP-414. opentelemetry-api is added as a mandatory dependency. It prov...

Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/pull/2381

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:37cd295d-1695-c996-a27f-0ad06ecb73e8
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id8E28:12F83A:3535E3:4BB6E6:6A622039
html-safe-noncedbe11ef64a2498d55b0732182c9a0e8875a219b6fe41c3ecdd2cbd65416192c1
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RTI4OjEyRjgzQTozNTM1RTM6NEJCNkU2OjZBNjIyMDM5IiwidmlzaXRvcl9pZCI6IjQ0Nzg3NzU5MjA3NzUyNzQ1NTMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac744440a4da82fd0ca8c24527ea41259c852d76eb1f94d8582473f219fc66dc92
hovercard-subject-tagpull_request:3473280202
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/modelcontextprotocol/python-sdk/pull/2381/files
twitter:imagehttps://avatars.githubusercontent.com/u/7353520?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/7353520?s=400&v=4
og:image:altSummary Adds OpenTelemetry tracing to MCP client and server request handling, with W3C trace context propagation via _meta per SEP-414. opentelemetry-api is added as a mandatory dependency. It prov...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonebe68eaf9abf2a202afbd94047d7200fb88b7edb0338f533bf171bbb1a69fab4e
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/modelcontextprotocol/python-sdk git https://github.com/modelcontextprotocol/python-sdk.git
octolytics-dimension-user_id182288589
octolytics-dimension-user_loginmodelcontextprotocol
octolytics-dimension-repository_id862584018
octolytics-dimension-repository_nwomodelcontextprotocol/python-sdk
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id862584018
octolytics-dimension-repository_network_root_nwomodelcontextprotocol/python-sdk
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release3d00b04c8874615454dfbdb32a7d2ca4db66d3f4
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/modelcontextprotocol/python-sdk/pull/2381/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fpull%2F2381%2Ffiles
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmodelcontextprotocol%2Fpython-sdk%2Fpull%2F2381%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=modelcontextprotocol%2Fpython-sdk
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/2381/files
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/2381/files
Reloadhttps://github.com/modelcontextprotocol/python-sdk/pull/2381/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2381/files
modelcontextprotocol https://github.com/modelcontextprotocol
python-sdkhttps://github.com/modelcontextprotocol/python-sdk
Notifications https://github.com/login?return_to=%2Fmodelcontextprotocol%2Fpython-sdk
Fork 3.7k https://github.com/login?return_to=%2Fmodelcontextprotocol%2Fpython-sdk
Star 23.7k https://github.com/login?return_to=%2Fmodelcontextprotocol%2Fpython-sdk
Code https://github.com/modelcontextprotocol/python-sdk
Issues 269 https://github.com/modelcontextprotocol/python-sdk/issues
Pull requests 314 https://github.com/modelcontextprotocol/python-sdk/pulls
Actions https://github.com/modelcontextprotocol/python-sdk/actions
Projects https://github.com/modelcontextprotocol/python-sdk/projects
Models https://github.com/modelcontextprotocol/python-sdk/models
Security and quality 6 https://github.com/modelcontextprotocol/python-sdk/security
Insights https://github.com/modelcontextprotocol/python-sdk/pulse
Code https://github.com/modelcontextprotocol/python-sdk
Issues https://github.com/modelcontextprotocol/python-sdk/issues
Pull requests https://github.com/modelcontextprotocol/python-sdk/pulls
Actions https://github.com/modelcontextprotocol/python-sdk/actions
Projects https://github.com/modelcontextprotocol/python-sdk/projects
Models https://github.com/modelcontextprotocol/python-sdk/models
Security and quality https://github.com/modelcontextprotocol/python-sdk/security
Insights https://github.com/modelcontextprotocol/python-sdk/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fmodelcontextprotocol%2Fpython-sdk%2Fissues%2Fnew%2Fchoose
maxisbeyhttps://github.com/maxisbey
mainhttps://github.com/modelcontextprotocol/python-sdk/tree/main
marcelo/otel-spanshttps://github.com/modelcontextprotocol/python-sdk/tree/marcelo/otel-spans
Conversation 13 https://github.com/modelcontextprotocol/python-sdk/pull/2381
Commits 16 https://github.com/modelcontextprotocol/python-sdk/pull/2381/commits
Checks 30 https://github.com/modelcontextprotocol/python-sdk/pull/2381/checks
Files changed https://github.com/modelcontextprotocol/python-sdk/pull/2381/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2381/files
Add basic OpenTelemetry tracing for client and server requests https://github.com/modelcontextprotocol/python-sdk/pull/2381/files#top
Show all changes 16 commits https://github.com/modelcontextprotocol/python-sdk/pull/2381/files
bbdd99b Add basic OpenTelemetry tracing for client and server requests Kludex Mar 31, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2381/commits/bbdd99bf9c347038238db56d9223a248eef98900
e1ebbc7 Make opentelemetry-api a mandatory dependency Kludex Mar 31, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2381/commits/e1ebbc7e5944523e93f68adfbcef4d037c6fda6c
7795f34 Use logfire[testing] for OTel test assertions Kludex Mar 31, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2381/commits/7795f34ec6afa4ca01a0721bf2ed49121cfd624e
e2d4b03 Use 'MCP send' prefix for outgoing request spans Kludex Mar 31, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2381/commits/e2d4b03e4cd9aebbcd159cf63b75fc979579f093
0e0b746 Propagate W3C trace context via _meta per SEP-414 Kludex Mar 31, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2381/commits/0e0b746b0cc203b66aec137ae00fd02f46e56caa
54f8787 Address review feedback on type annotations and _meta injection Kludex Mar 31, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2381/commits/54f87874d2e8731567b7e44b5f44b1376231542d
a700ab9 Merge branch 'main' into marcelo/otel-spans Kludex Mar 31, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2381/commits/a700ab91dd5ffbc41c90d262ac5389114e24a22c
2369988 Skip OTel test when logfire.testing is not available Kludex Mar 31, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2381/commits/2369988904570ffc2af8e0d1a90478c9118c5aef
f43dc4a Merge branch 'marcelo/otel-spans' of github.com:modelcontextprotocol/… Kludex Mar 31, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2381/commits/f43dc4a86da5ac993530caf8f75b5e949e58c0a8
0391854 Pin logfire>=3.0.0 dev dependency and restore direct import Kludex Mar 31, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2381/commits/03918548d8b84515af22c600528bc9541af66c2d
1ee1dfd Use single backticks in docstrings Kludex Mar 31, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2381/commits/1ee1dfd9a60b3e75deb1cd445f76a3e59fce69c7
d9dcc85 Record ERROR status on server spans for error responses Kludex Mar 31, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2381/commits/d9dcc85b5bda9c74e3d1f1d9e90ea0c84675a1e0
f79767e Move StatusCode import to top of file Kludex Mar 31, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2381/commits/f79767e3221c97fea2a5a23f67184907b7b76459
8ae416e Use SpanKind enum directly instead of string conversion Kludex Mar 31, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2381/commits/8ae416e9bfa0b9a701f427b693c42d89435b8c89
b47c9c5 Add comment explaining filterwarnings on OTel test Kludex Mar 31, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2381/commits/b47c9c5cf91ba232290a403227104fe444ee9a0b
e00d336 Use isinstance assert instead of type: ignore in OTel test Kludex Mar 31, 2026 https://github.com/modelcontextprotocol/python-sdk/pull/2381/commits/e00d336ee6cc26ac2dd08ca7eec4e2e7dd8ef89b
Clear filters https://github.com/modelcontextprotocol/python-sdk/pull/2381/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2381/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2381/files
pyproject.toml https://github.com/modelcontextprotocol/python-sdk/pull/2381/files#diff-50c86b7ed8ac2cf95bd48334961bf0530cdc77b5a56f852c5c61b89d735fd711
server.py https://github.com/modelcontextprotocol/python-sdk/pull/2381/files#diff-b21bf5e21c058ccfddb404c209f2d4288e4f32b121111ffc9d466638631d13e4
_otel.py https://github.com/modelcontextprotocol/python-sdk/pull/2381/files#diff-f7b9208e58bf90e0bfe4ecf1f810dfdb14524bbd475f9f8e01c3df04355bd598
session.py https://github.com/modelcontextprotocol/python-sdk/pull/2381/files#diff-aaa1596dd4db91f5cd7f743c8afbe58596daf01a2ecec4a0024768f7409fb1dc
test_otel.py https://github.com/modelcontextprotocol/python-sdk/pull/2381/files#diff-84f003b56f0cb53b4aa8d9c9b77caceba5fdebd6874448f02410dffb0815cbaa
uv.lock https://github.com/modelcontextprotocol/python-sdk/pull/2381/files#diff-84321598744d84dbee2318e634c74c9aae39a1c253f1c4bd17ebf9ef2f807b11
pyproject.tomlhttps://github.com/modelcontextprotocol/python-sdk/pull/2381/files#diff-50c86b7ed8ac2cf95bd48334961bf0530cdc77b5a56f852c5c61b89d735fd711
View file https://github.com/modelcontextprotocol/python-sdk/blob/e00d336ee6cc26ac2dd08ca7eec4e2e7dd8ef89b/pyproject.toml
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/2381/{{ revealButtonHref }}
https://github.com/modelcontextprotocol/python-sdk/pull/2381/files#diff-50c86b7ed8ac2cf95bd48334961bf0530cdc77b5a56f852c5c61b89d735fd711
https://github.com/modelcontextprotocol/python-sdk/pull/2381/files#diff-50c86b7ed8ac2cf95bd48334961bf0530cdc77b5a56f852c5c61b89d735fd711
https://github.com/modelcontextprotocol/python-sdk/pull/2381/files#diff-50c86b7ed8ac2cf95bd48334961bf0530cdc77b5a56f852c5c61b89d735fd711
https://github.com/modelcontextprotocol/python-sdk/pull/2381/files#diff-50c86b7ed8ac2cf95bd48334961bf0530cdc77b5a56f852c5c61b89d735fd711
src/mcp/server/lowlevel/server.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/2381/files#diff-b21bf5e21c058ccfddb404c209f2d4288e4f32b121111ffc9d466638631d13e4
View file https://github.com/modelcontextprotocol/python-sdk/blob/e00d336ee6cc26ac2dd08ca7eec4e2e7dd8ef89b/src/mcp/server/lowlevel/server.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/2381/{{ revealButtonHref }}
https://github.com/modelcontextprotocol/python-sdk/pull/2381/files#diff-b21bf5e21c058ccfddb404c209f2d4288e4f32b121111ffc9d466638631d13e4
https://github.com/modelcontextprotocol/python-sdk/pull/2381/files#diff-b21bf5e21c058ccfddb404c209f2d4288e4f32b121111ffc9d466638631d13e4
https://github.com/modelcontextprotocol/python-sdk/pull/2381/files#diff-b21bf5e21c058ccfddb404c209f2d4288e4f32b121111ffc9d466638631d13e4
https://github.com/modelcontextprotocol/python-sdk/pull/2381/files#diff-b21bf5e21c058ccfddb404c209f2d4288e4f32b121111ffc9d466638631d13e4
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2381/files
claudehttps://github.com/apps/claude
Mar 31, 2026https://github.com/modelcontextprotocol/python-sdk/pull/2381/files#r3017819388
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2381/files
Kludexhttps://github.com/Kludex
Mar 31, 2026https://github.com/modelcontextprotocol/python-sdk/pull/2381/files#r3017992800
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2381/files
https://github.com/modelcontextprotocol/python-sdk/pull/2381/files#diff-b21bf5e21c058ccfddb404c209f2d4288e4f32b121111ffc9d466638631d13e4
src/mcp/shared/_otel.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/2381/files#diff-f7b9208e58bf90e0bfe4ecf1f810dfdb14524bbd475f9f8e01c3df04355bd598
View file https://github.com/modelcontextprotocol/python-sdk/blob/e00d336ee6cc26ac2dd08ca7eec4e2e7dd8ef89b/src/mcp/shared/_otel.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/2381/{{ revealButtonHref }}
src/mcp/shared/session.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/2381/files#diff-aaa1596dd4db91f5cd7f743c8afbe58596daf01a2ecec4a0024768f7409fb1dc
View file https://github.com/modelcontextprotocol/python-sdk/blob/e00d336ee6cc26ac2dd08ca7eec4e2e7dd8ef89b/src/mcp/shared/session.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/2381/{{ revealButtonHref }}
https://github.com/modelcontextprotocol/python-sdk/pull/2381/files#diff-aaa1596dd4db91f5cd7f743c8afbe58596daf01a2ecec4a0024768f7409fb1dc
https://github.com/modelcontextprotocol/python-sdk/pull/2381/files#diff-aaa1596dd4db91f5cd7f743c8afbe58596daf01a2ecec4a0024768f7409fb1dc
https://github.com/modelcontextprotocol/python-sdk/pull/2381/files#diff-aaa1596dd4db91f5cd7f743c8afbe58596daf01a2ecec4a0024768f7409fb1dc
claudehttps://github.com/apps/claude
Mar 31, 2026https://github.com/modelcontextprotocol/python-sdk/pull/2381/files#r3017788848
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2381/files
Kludexhttps://github.com/Kludex
Mar 31, 2026https://github.com/modelcontextprotocol/python-sdk/pull/2381/files#r3017991728
Learn morehttps://docs.github.com/articles/managing-disruptive-comments/#hiding-a-comment
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2381/files
https://github.com/modelcontextprotocol/python-sdk/pull/2381/files#diff-aaa1596dd4db91f5cd7f743c8afbe58596daf01a2ecec4a0024768f7409fb1dc
tests/shared/test_otel.pyhttps://github.com/modelcontextprotocol/python-sdk/pull/2381/files#diff-84f003b56f0cb53b4aa8d9c9b77caceba5fdebd6874448f02410dffb0815cbaa
View file https://github.com/modelcontextprotocol/python-sdk/blob/e00d336ee6cc26ac2dd08ca7eec4e2e7dd8ef89b/tests/shared/test_otel.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/modelcontextprotocol/python-sdk/pull/2381/{{ revealButtonHref }}
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2381/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2381/files
Please reload this pagehttps://github.com/modelcontextprotocol/python-sdk/pull/2381/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.