Eine aufbereitete Darstellung der Quelle

 
     
 
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung


Quelle  test_opentelemetry.py   Sprache: Python

 

"""`docs/run/opentelemetry.md`: every claim the page makes, proved against the real SDK."""

import pytest
from logfire.testing import CaptureLogfire

from docs_src.opentelemetry import tutorial001
from mcp import Client

# See test_index.py for why this is a per-module mark and not a conftest hook.
pytestmark = [pytest.mark.anyio, pytest.mark.filterwarnings("error::mcp.MCPDeprecationWarning")]


async def test_a_plain_server_is_traced_with_no_extra_code(capfire: CaptureLogfire) -> None:
    """tutorial001: calling a tool emits a `tools/call` SERVER span, though the example adds no middleware."""
    async with Client(tutorial001.mcp) as client:
        await client.call_tool("search_books", {"query": "dune"})

    spans = {s["name"]: s for s in capfire.exporter.exported_spans_as_dict()}
    assert "tools/call search_books" in spans

    attributes = spans["tools/call search_books"]["attributes"]
    assert attributes["mcp.method.name"] == "tools/call"
    assert attributes["gen_ai.operation.name"] == "execute_tool"
    assert attributes["gen_ai.tool.name"] == "search_books"


async def test_client_and_server_share_one_trace(capfire: CaptureLogfire) -> None:
    """When both sides run the SDK, the client and server spans land in one trace (SEP-414)."""
    async with Client(tutorial001.mcp, mode="legacy") as client:
        await client.call_tool("search_books", {"query": "dune"})

    spans = {s["name"]: s for s in capfire.exporter.exported_spans_as_dict()}
    client_span = spans["MCP send tools/call search_books"]
    server_span = spans["tools/call search_books"]
    assert server_span["context"]["trace_id"] == client_span["context"]["trace_id"]

Messung
CHZG
82929589

¤ Dauer der Verarbeitung: 0.1 Sekunden  (vorverarbeitet am  2026-11-24) ¤

*© Formatika GbR, Deutschland







                                                                                                                                                                                                                                                                                                                                                                                                     

 

Neuigkeiten

Aktuelles
Motto des Tages

Open Source Software


Gedichte
Musik
Bilder

Jenseits des Üblichen

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1,188,296
#Domains=919,356