Skip to content

feat: Add otel support for client - #1504

Draft
Iwaniukooo11 wants to merge 4 commits into
a2aproject:mainfrom
Iwaniukooo11:mateusziwaniuk/feat/otel-plugin-skeleton
Draft

Iwaniukooo11 wants to merge 4 commits into
a2aproject:mainfrom
Iwaniukooo11:mateusziwaniuk/feat/otel-plugin-skeleton

Conversation

@Iwaniukooo11

@Iwaniukooo11 Iwaniukooo11 commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Description

Adds OpenTelemetryPlugin with client support

  • A2A_OTEL_PLUGIN_ENABLED=false turns it into a no-op.
  • Not having opentelemtry-sdk installed raises

OTEL unrelated change

_execute_with_interceptors in base_client.py now calls after_client_request in finally.
Before, a cancelled unary call (for example a timeout) skipped the hook, so its span was never ended.

Actual change

  • One CLIENT span per call, named with the semconv method name
  • traceparent is injected into the outgoing headers, so the agent can join the trace.
  • wrap_client_call makes the span current

Assumptions

  • ListTasks: task id and context id are never reported, whatever the number of tasks.
  • Streaming: task state is skipped, as it changes during the stream. Task id and context id are still reported, as they stay the same across events.
  • Task id: read from task_id first. id is used only where it is the task id (GetTask, CancelTask, SubscribeToTask, a Task response). On push config requests id is the config id, so it is never reported.
  • use_span runs with record_exception=False and set_status_on_exception=False. Otherwise OTel adds an exception span event and sets the status on its own. Span events are out of scope, and the status is set only in our final hook.
  • schema_url is not set yet, as semantic-conventions-genai has no release.

Tests

  • Span name and kind for every method, and the unknown method fallback.
  • Task attributes for unary, streaming and ListTasks, and task id vs config id.
  • Interface, tenant, message and agent card attributes, with empty values omitted.
  • Trace propagation and span nesting.
  • Error status and error.type, an error mid-stream, and success leaving the status unset.
  • Timeout, cancelled stream and early close all end the span.
  • Disabled plugin and missing OpenTelemetry.

@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

🧪 Code Coverage (vs main)

⬇️ Download Full Report

Base PR Delta
src/a2a/client/base_client.py 96.74% 96.77% 🟢 +0.04%
src/a2a/plugins/otel/_plugin.py (new) — 97.06% —
src/a2a/plugins/otel/_semconv.py (new) — 94.12% —
Total 93.81% 93.87% 🟢 +0.05%

Generated by coverage-comment.yml

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant