docs: clarify OpenTelemetry spans for resources and prompts

Closed
JO
18d ago
+50-4

What changed

  • Expanded the OpenTelemetry docs example to include a resource and a prompt.
  • Clarified that resources/read and prompts/get are traced by the same request-level server middleware as tools.
  • Documented that prompts/get gets gen_ai.prompt.name, while resources/read currently carries the common MCP attributes without adding the resource URI to the span name or gen_ai.* attributes.
  • Added a docs-source test that verifies the resource and prompt span behavior.

Why it changed

Issue #766 asks where instrumentation for resources and prompts should happen. The docs already covered tool spans, but resource and prompt behavior was less explicit.

How it was validated

  • uv run pytest tests/docs_src/test_opentelemetry.py
  • uv run pytest tests/docs_src/test_shape.py
  • uv run pytest tests/server/test_otel.py
  • uv run ruff check docs_src/opentelemetry tests/docs_src/test_opentelemetry.py
  • uv run ruff format --check docs_src/opentelemetry tests/docs_src/test_opentelemetry.py
  • uv run pyright docs_src/opentelemetry tests/docs_src/test_opentelemetry.py
  • uv run mkdocs build --strict

Related issue

Refs #766

Disclosure: AI assistance was used while preparing this PR; I reviewed the changes and take responsibility for them.