Skip to content

feat: Add opentelemtry server plugin support - #1524

Merged
Iwaniukooo11 merged 10 commits into
a2aproject:mateusziwaniuk/feat-otelfrom
Iwaniukooo11:mateusziwaniuk/feat/otel-server
Nov 27, 2026
Merged

Iwaniukooo11 merged 10 commits into
a2aproject:mateusziwaniuk/feat-otelfrom
Iwaniukooo11:mateusziwaniuk/feat/otel-server

Conversation

@Iwaniukooo11

@Iwaniukooo11 Iwaniukooo11 commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Changes:

  • Plugged Otel into hooks: before, wrap, after
  • _CallState gains is_owned (True if standalone, False if enrichment) - We can't close span which is not owned by server
  • _grpc_carrier is introduced to avoid errors when gRPC metadata are empty / are not UTF-8
  • Little refactor of handling request / response attributes to ensure better readability (and splitting logic for ClientRequest / ServerRequest)

Assumptions / Decisions

  • a2a version is read from header
  • legacy otel now warns about deprecation
  • if both legacy otel and new otel run at the same time, legacy otel is turned off
  • server doesn't collect client host / port

Tests

  • Done manual testing using jaeger
  • Mainly extended previous ones
  • Ensured proper legacy handling
  • Tested tenant separately
  • Handling cancellations
  • handling enrichment vs standalone + span creation and nesting
  • Version reading

@Iwaniukooo11 Iwaniukooo11 changed the title Mateusziwaniuk/feat/otel server feat: Add opentelemtry server plugin support Nov 25, 2026
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

🧪 Code Coverage (vs mateusziwaniuk/feat-otel)

⬇️ Download Full Report

Base PR Delta
src/a2a/plugins/otel/plugin.py 97.50% 95.00% 🔴 -2.50%
src/a2a/utils/telemetry.py 90.70% 91.61% 🟢 +0.91%
Total 94.19% 94.17% 🔴 -0.03%

Generated by coverage-comment.yml

@Iwaniukooo11
Iwaniukooo11 marked this pull request as ready for review November 25, 2026 15:37
@Iwaniukooo11
Iwaniukooo11 requested a review from a team as a code owner November 25, 2026 15:37
@Iwaniukooo11
Iwaniukooo11 marked this pull request as draft November 25, 2026 15:38
@Iwaniukooo11
Iwaniukooo11 marked this pull request as ready for review November 26, 2026 10:27

@mykytanetipa mykytanetipa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall, left minor comments

Comment thread src/a2a/plugins/otel/plugin.py Resolved
Comment thread src/a2a/plugins/otel/plugin.py Resolved
Comment thread src/a2a/plugins/otel/plugin.py Resolved
@Iwaniukooo11
Iwaniukooo11 merged commit e1ce851 into a2aproject:mateusziwaniuk/feat-otel Nov 27, 2026
24 checks passed
Iwaniukooo11 added a commit that referenced this pull request Nov 27, 2026
## Description
- Adds `OpenTelemetryPlugin`, which reports A2A client and server calls
as spans, aligned with open-telemetry/semantic-conventions-genai#195.
- Combines #1504 and #1524, nothing else added.
- Marked `@experimental`. `A2A_OTEL_PLUGIN_ENABLED=false` turns it into
a no-op, and creating it without OpenTelemetry installed raises an error
with an install hint.
- Client: one `CLIENT` span per call, named after the A2A method;
`traceparent` is sent so the server joins the trace.
- Server: reuses the HTTP/gRPC transport span if there is one
(enrichment), otherwise creates its own `SERVER` span under the caller's
trace (standalone). It only ends spans it created.
- Legacy tracing (`a2a.utils.telemetry`) is deprecated and turned off
once the plugin is created, so calls aren't traced twice.
- btw: the client's after-request hook now always runs, so a cancelled
or timed-out call still ends its span.

## Assumptions
- `ListTasks` never reports task or context ids.
- Streaming calls don't report task state, because it changes during the
stream.
- Push config requests don't report a task id, because their `id` is the
config id.
- Server spans read the protocol version from the `A2A-Version` header.
- A server span is treated as a transport span only if it has HTTP or
gRPC attributes (same rule as a2a-go).
- Server spans don't report the client's host or port.
- `schema_url` is left unset until `semantic-conventions-genai` is
released.

## Tests
- Span name and kind for every method, client and server.
- Attributes for unary, streaming and `ListTasks` calls.
- Trace propagation and span nesting, including gRPC metadata edge
cases.
- Reusing the transport span vs creating a new one.
- Errors, cancellation, timeouts and early stream close.
- Disabled plugin, missing OpenTelemetry, and legacy tracing handling.
- **Manual end-to-end run with Jaeger**
- 
Release-As: 1.4.0
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.

2 participants