Skip to content

Commit 22ce0f9

Browse files
committed
🎨💡 Improve comment and format
Signed-off-by: Evaline Ju <69598118+evaline-ju@users.noreply.github.com>
1 parent 2da51cf commit 22ce0f9

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

a2a/weather_service/src/weather_service/graph.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def get_mcpclient(headers=None):
3131
mcp_config["headers"] = headers
3232
return MultiServerMCPClient({"math": mcp_config})
3333

34+
3435
async def get_graph(client) -> StateGraph:
3536
llm = ChatOpenAI(
3637
model=config.llm_model,

a2a/weather_service/src/weather_service/observability.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,13 @@ def setup_observability() -> None:
139139
# tool call will automatically carry the current span's traceparent header
140140
try:
141141
from opentelemetry.instrumentation.httpx import HTTPXClientInstrumentor
142+
142143
HTTPXClientInstrumentor().instrument()
143144
logger.info("httpx instrumented for automatic trace context propagation")
144145
except ImportError:
145-
logger.warning("opentelemetry-instrumentation-httpx not available - "
146-
"MCP tool calls will not propagate trace context")
146+
logger.warning(
147+
"opentelemetry-instrumentation-httpx not available - MCP tool calls will not propagate trace context"
148+
)
147149

148150
# Instrument OpenAI for GenAI semantic conventions
149151
try:
@@ -443,7 +445,9 @@ async def tracing_middleware(request: Request, call_next):
443445
logger.debug(f"Could not parse request body: {e}")
444446

445447
# Extract incoming W3C Trace Context from request headers to connect
446-
# agent spans to MCP gateway spans
448+
# agent spans to MCP gateway spans. Callers without traceparent still
449+
# get root spans (extract returns empty context), while callers with traceparent
450+
# (like MCP gateway) get connected end-to-end traces
447451
incoming_ctx = extract(dict(request.headers))
448452
detach_token = context.attach(incoming_ctx)
449453

0 commit comments

Comments
 (0)