Add a2a operation metrics to otel semconv #651
<a href="https://easycla.lfx.linuxfoundation.org/#/?version=2"><img src="https://s3.amazonaws.com/cla-project-logo-prod/cla-signed.svg?v=2" alt="CLA Signed" align="left" height="28" width="328" ></a><br >The committers listed above are authorized under a signed CLA.<ul><li>:white_check_mark: login: polchernikova-w / name: Palina Chernikava (d51b1f4a921ef0c0497dcd049daa7e6aa9c150b6)</li></ul>
<!-- pull-request-dashboard-status -->
<!-- pull-request-dashboard-status-revision:24 -->
Pull request dashboard status
Waiting on reviewers · refreshed 2026-11-26 10:53 UTC
Review the latest changes.
<details>
<summary>Status above doesn't look right?</summary>
<br>
/dashboard route:author to route it back.</details>
Reference coverage leaves the other A2A scenario unchanged. reference/scenarios/adk_a2a/scenario.py:62-77 serves a real A2A application and calls an SDK client's send_message, but its committed telemetry contains none of the four new A2A operation metrics. Extend that scenario at the client/server SDK boundaries as well, using its request and Agent Card values, and refresh its telemetry and reports so coverage includes the ADK-backed integration.
The client duration and active-operation interval include client construction and cleanup, exceeding the request-to-response or last-consumed-event boundaries in model/a2a/metrics.yaml:29-31. Create the client outside the operation span and metrics, and finish recording inside its context, including catching the expected GetTask error there. Apply the same change to the streaming call at line 451 and the successful and failed GetTask calls at lines 512 and 551.
<!-- ccr-overview-v2 -->
🟡 Changes recommended
Client metrics include construction and cleanup outside the defined operation boundaries, and the ADK-backed A2A scenario lacks coverage for all four new operation metrics.
<details open>
<summary><strong>2 open issues</strong></summary>
</details>
<details>
<summary><strong>What changed in this PR</strong></summary>
Adds A2A operation metrics alongside the span conventions introduced in #195. This covers the operation-metrics portion of #254; streaming-event and task-lifecycle metrics remain deferred.
Changes:
| File | Description |
| ---- | ----------- |
| reference/src/semconv_genai/semconv_model.py | Registers display names for the four metrics. |
| reference/src/semconv_genai/report.py | Links metric reports to their documentation. |
| reference/scenarios/a2a-python/scenario.py | Records operation metrics and exercises a client error. |
| reference/scenarios/a2a-python/data.json | Updates captured metric and attribute coverage. |
| reference/scenarios/a2a-python/conformance.yaml | Adds the client task-not-found span expectation. |
| reference/reports/a2a-server-operation-duration-metric.md | Reports server duration attribute coverage. |
| reference/reports/a2a-server-active-operations-metric.md | Reports server active-operation attribute coverage. |
| reference/reports/a2a-client-operation-duration-metric.md | Reports client duration attribute coverage. |
| reference/reports/a2a-client-active-operations-metric.md | Reports client active-operation attribute coverage. |
| reference/README.md | Lists the four new metric reports. |
| model/a2a/registry.yaml | Defines binding and return-immediately attributes. |
| model/a2a/metrics.yaml | Defines metrics, timing boundaries, and attribute requirements. |
| model/a2a/common.yaml | Shares error attributes between spans and metrics. |
| docs/registry/attributes/a2a.md | Adds generated documentation for the new attributes. |
| docs/gen-ai/a2a.md | Documents metrics and recommended histogram buckets. |
| changelog.d/651.enhancement.md | Announces the new metrics and attributes. |
</details>
<sub>Review effort: Balanced</sub>
The adk_a2a scenario is not responsible for a2a telemetry, a scenario shouldn't re-emit telemetry that belongs to another library
Could a2a.protocol.binding move to a separate PR? It's a new concept that needs its own discussion, and the metrics can land without it.
Main reason for it is that we decided against adding similar attribute for MCP, instead we use existing otel attributes Recording MCP transport. Please consider if it can be an option here.
If the handler raises, active_operations is never decremented and no duration is recorded. Instrumentations tend to copy reference scenarios, so could the record and decrement go in a finally, with error.type set from the exception? The same applies to the client calls in run_message_send_reference, run_message_stream_reference and run_tasks_get_reference.
Measured from when the client sends the request until the response is
received for non-streaming calls, until the last event of the response
stream is consumed for streaming calls, or when operation ends with an error.
same nit on the error
nit, following updated metric guidance (don't pluralize updowncounters), let's do
- name: a2a.client.operation.active
same for server
Why only on metrics? It would be useful on the a2a.client and a2a.server spans for SendMessage too: it explains why one span takes milliseconds and another takes minutes, and it keeps span and metric attributes aligned.
#655 aligns GenAI and MCP duration buckets with the upstream 1, 2.5, 5 sequence. Could these buckets follow it?
of `[ 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10, 30, 60, 120, 300 ]`.
Same as above, to align with #655.
of `[ 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10, 30, 60, 120, 300 ]`.
_DURATION_BUCKETS = [0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10, 30, 60, 120, 300]
Instrumentation SHOULD record the effective
value: when the request does not set the field, record the protocol
default,
false.why? it just adds telemetry volume and makes instrumentation assume defaults. Let's not set it unless it's explicitly provided (or not set when it's not provided or false)?
Moved to a separate CL, but just for future reference - the network.protocol.* doesn't work here because the grpc is not a network protocol, and rpc.system.name is also not an option because it has no value for http. I remove it now and will open a separate PR for it.
Make sense, removed the default
Added for spans. Let me know if you'd prefer it to be a separate PR
Read through this from the A2A side (I work on A2A conformance across the SDKs). The duration boundaries line up with the spec's execution modes (§3.2.2: a blocking SendMessage waits for a terminal or interrupted state), and the earlier feedback looks addressed. Three things:
1. a2a.operation.return_immediately for A2A 0.3 requests. SDKs with a 0.3 compat layer (a2a-python, a2a-java, a2a-dotnet) serve 0.3 clients on the same server, and a2a.protocol.version can be 0.3. 0.3 has no returnImmediately; it has MessageSendConfiguration.blocking with the opposite meaning, and the compat layers convert it as return_immediately = !blocking. That case matters in practice: a2a-dotnet's v0.3 model defaults blocking to false and always serializes it, so its 0.3 clients send non-blocking requests unless they set it explicitly (a2aproject/a2a-dotnet#386). Those calls come back early, which is exactly what this attribute is meant to explain. Maybe one sentence in the note, e.g. "For A2A 0.3 requests, which carry blocking instead, set it to true when blocking is false."
2. Question: a2a.task.state on the duration metrics? A blocking SendMessage returns either at a terminal state or at an interrupted one (TASK_STATE_INPUT_REQUIRED / TASK_STATE_AUTH_REQUIRED), so the histogram mixes "the agent finished" with "the agent stopped to ask for input". That's the same reasoning as for return_immediately. It's low-cardinality, and the spans already omit it when there are several states. Fine to leave for the task-lifecycle follow-up if that's the plan.
3. Scenario: the server streaming path can leak a2a.server.operation.active. In ReferenceJsonRpcDispatcher, a streaming response records the duration and decrements the counter only in the finally of traced_events(), and the outer finally skips it when streaming is set. If the client is gone before the response starts, Starlette raises ClientDisconnect while sending http.response.start and never iterates the body, so that finally doesn't run: the counter stays incremented and no duration is recorded. I reproduced it with Starlette 1.10.0 (the version in the scenario's lock) using a StreamingResponse whose body_iterator is wrapped the same way. Since instrumentations tend to copy the reference scenarios, it may be worth recording around the response's ASGI call instead, so it runs whether or not the body was iterated, with a flag so it's recorded only once.
Read through this from the A2A side (I work on A2A conformance across the SDKs). The duration boundaries line up with the spec's execution modes (§3.2.2: a blocking SendMessage waits for a terminal or interrupted state), and the earlier feedback looks addressed. Three things:
> 1.a2a.operation.return_immediatelyfor A2A 0.3 requests. SDKs with a 0.3 compat layer (a2a-python, a2a-java, a2a-dotnet) serve 0.3 clients on the same server, anda2a.protocol.versioncan be0.3. 0.3 has noreturnImmediately; it hasMessageSendConfiguration.blockingwith the opposite meaning, and the compat layers convert it asreturn_immediately = !blocking. That case matters in practice: a2a-dotnet's v0.3 model defaultsblockingtofalseand always serializes it, so its 0.3 clients send non-blocking requests unless they set it explicitly (a2aproject/a2a-dotnet#386). Those calls come back early, which is exactly what this attribute is meant to explain. Maybe one sentence in the note, e.g. "For A2A 0.3 requests, which carryblockinginstead, set it totruewhenblockingisfalse."
> 2. Question:a2a.task.stateon the duration metrics? A blockingSendMessagereturns either at a terminal state or at an interrupted one (TASK_STATE_INPUT_REQUIRED/TASK_STATE_AUTH_REQUIRED), so the histogram mixes "the agent finished" with "the agent stopped to ask for input". That's the same reasoning as forreturn_immediately. It's low-cardinality, and the spans already omit it when there are several states. Fine to leave for the task-lifecycle follow-up if that's the plan.
> 3. Scenario: the server streaming path can leaka2a.server.operation.active. InReferenceJsonRpcDispatcher, a streaming response records the duration and decrements the counter only in thefinallyoftraced_events(), and the outerfinallyskips it whenstreamingis set. If the client is gone before the response starts, Starlette raisesClientDisconnectwhile sendinghttp.response.startand never iterates the body, so thatfinallydoesn't run: the counter stays incremented and no duration is recorded. I reproduced it with Starlette 1.10.0 (the version in the scenario's lock) using aStreamingResponsewhosebody_iteratoris wrapped the same way. Since instrumentations tend to copy the reference scenarios, it may be worth recording around the response's ASGI call instead, so it runs whether or not the body was iterated, with a flag so it's recorded only once.
Thank you for the review!
1. I understand that those two parameters carry the same goal (but carry the opposite meaning) in different protocol versions, but "set return_immediately to true when blocking is false" sounds like something which belongs to the a2a specification, not the opentelemetry semantic convention.
2. Sounds reasonable, but I'd defer it for the task-lifecycle follow-up.
3. Fixed, thanks a lot
The reference dispatcher copies body["method"] into both server metrics before SDK validation, so distinct nonexistent method names create distinct time series. This can exhaust metric cardinality limits and crowd out valid operation measurements. Define a bounded fallback such as _OTHER for unrecognized methods in the model and apply it in the dispatcher, while preserving recognized SDK and extension methods.
Malformed SendMessage requests can permanently inflate a2a.server.operation.active. For example, a nonempty string in params.configuration raises AttributeError after the +1 but before the cleanup try/finally, so no duration or matching -1 is recorded. Move the increment after fallible request and span setup, immediately before the protected block.
<!-- ccr-overview-v2 -->
🟡 Changes recommended
Malformed requests can permanently inflate the active-operation metric, and unvalidated method names can create unbounded metric cardinality.
<details open>
<summary><strong>2 open issues</strong></summary>
</details>
<details>
<summary><strong>2 resolved since last review</strong></summary>
</details>
<sub>Review effort: Balanced</sub>
MCP (mcp.method.name) and the other GenAI metrics don't use an _OTHER fallback, so I'm leaving this out for now to stay consistent
<!-- ccr-overview-v2 -->
🔵 Needs a closer look
The HTTP-enriched scenario does not emit the newly added a2a.operation.return_immediately attribute, leaving it undemonstrated on the enriched transport span and missing a corresponding conformance match.
No open issues 🎉
<details>
<summary><strong>1 previously missed issue</strong></summary>
In code that hasn't changed since last review
<details>
<summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.png" alt="Medium severity" width="62" height="18" align="texttop"></picture> Exercise return_immediately on the HTTP transport span</summary>
model/a2a/common.yaml:25
This shared group adds a2a.operation.return_immediately to the HTTP server refinement, but the existing HTTP-enriched scenario never emits it. The only return_immediately=True call targets standalone; run_server_over_http_reference leaves the configuration unset. .github/instructions/evaluate-reference.instructions.md:40 requires flagging scenarios that could emit a changed attribute but do not. Please send a non-blocking SendMessage through over_http and add a corresponding conformance match so the new field is demonstrated on the enriched transport span too.
</details>
</details>
<details>
<summary><strong>2 resolved since last review</strong></summary>
</details>
<sub>Review effort: Balanced</sub>
The timer includes await request.json(), but _server_active is incremented only after body parsing and span setup. A slow upload therefore counts toward duration without contributing to the active-operation count, violating the shared boundaries in model/a2a/metrics.yaml:74-76. Move the timer start next to the active increment at the SDK dispatch boundary.
<!-- ccr-overview-v2 -->
🟡 Changes recommended
The duration timer starts before request-body parsing, while the active-operation count starts afterward, violating the metrics’ required shared boundaries during slow uploads.
<details open>
<summary><strong>1 open issue</strong></summary>
</details>
<sub>Review effort: Balanced</sub>
<!-- ccr-overview-v2 -->
🔵 Needs a closer look
Human assessment is needed because malformed request configuration can cause instrumentation to raise an unhandled server error before SDK validation and bypass operation metrics.
No open issues 🎉
<details>
<summary><strong>1 resolved since last review</strong></summary>
</details>
<sub>Review effort: Balanced</sub>
<!-- ccr-overview-v2 -->
🔵 Needs a closer look
A minor changelog-formatting finding was omitted from the published review, so its impact on approval requires human judgment.
No open issues 🎉
<sub>Review effort: Balanced</sub>
<!-- ccr-overview-v2 -->
🟢 Approval recommended
No active review issues remain for the A2A operation-metrics additions.
No open issues 🎉
<sub>Review effort: Balanced</sub>
This is a request parameter rather than a property of the operation, and a2a.operation. would be a new namespace. What do you think about following gen_ai.request.stream / gen_ai.request. and calling it a2a.request.return_immediately? That leaves room for other SendMessageConfiguration fields later (e.g. historyLength, acceptedOutputModes).
- key: a2a.request.return_immediately
nit: the brief already scopes this to SendMessage, so the condition can be shorter (same in metrics.yaml).
conditionally_required: >
If and only if the value is `true`. When missing, the value is
assumed to be `false`.
nit: a bit shorter, same meaning:
brief: >
Whether `SendMessage` was requested to return before the task reaches
a terminal or interrupted state.
nit: "produced" vs "sent" for the two cases; using one verb keeps the boundary unambiguous.
Measured from when the server starts handling the request until the
response is sent for non-streaming calls, until the last event of
the response stream is sent for streaming calls, or until the operation
ends with an error.
nit: "same boundaries as" already covers increment/decrement; same for the server metric.
Follows the same boundaries as `a2a.client.operation.duration`.
nit: shorten
"""Record the metric and end the span once the response is sent, even if
the client disconnects before the body iterator runs.
"""
Thanks! Fine to keep it in this PR.
Digging into this, I think our A2A span design needs another look. A2A 1.0 blocks by default, so a default SendMessage is an agent invocation. I opened #730 for it.
Whatever we pick there shouldn't break the metrics here. What do you think of the options in the issue?
Looks good, mostly suggestions to shorten description, the only substantial comment is on the new attribute naming
Left a couple inline comments on metric attribute cardinality and missing status/transport labels.
Two PR-level questions:
a2a.protocol.binding: I saw this was moved out to #612 (+1 on Option 1 there). Since a2a..operation. has no http., rpc., or network.* attributes, there's currently no way to break down latency, errors, or active operations by binding (JSONRPC vs HTTP+JSON vs GRPC). Could we either keep a2a.protocol.binding here or make sure #612 adds it to these four metrics too?a2a.{client,server}.{request,response}.size histograms (similar to mcp.{client,server}.{request,response}.size in #600) planned in the followup? Tracking payload sizes would be very useful since large task contexts and artifacts directly consume the caller's LLM context window.Two things on the operation/duration metric attributes:
1. a2a.method.name is an open enum and Required on all four metrics. On JSON-RPC servers, method comes straight from the request body, so unknown/arbitrary method names from callers or scanners can blow up metric cardinality. Should we add _OTHER (like http.request.method and rpc.method) for unrecognized methods on metrics?
2. Compared to mcp.*.operation.duration, we're missing transport/RPC status attributes here:
- rpc.response.status_code: right now if ErrorInfo.reason is set (e.g. TASK_NOT_FOUND), error.type uses that and drops the JSON-RPC error code (-32001) or gRPC status. Also gateways/proxies that only inspect unary JSON-RPC error.code won't parse ErrorInfo.
- http.response.status_code and http.request.method (when over HTTP): since JSONRPC and HTTP+JSON run over HTTP and JSON-RPC errors often come back in HTTP 200, having HTTP status/method helps separate L7 gateway errors (401/403/429/5xx) from L8 A2A errors.
Sounds good, done. Thanks!
1. Was already pushed back here https://github.com/open-telemetry/semantic-conventions-genai/pull/651#discussion_r4612369661
2. The A2A spec gives every Error a specfic status code for every transport link, so http.response.status_code is redundant. Same for http.request.method: the A2A spec has this. Overall, I can't find where mcp adopt http.response.status_code or http.request.method. From what I can see, they use network.* attributes, which doesn't fit A2A same as here https://github.com/open-telemetry/semantic-conventions-genai/pull/651#discussion_r4453758005. It deserves some discussion so I'd leave it for out of this PR.
<!-- pull-request-dashboard-author-nudge:783d24a4c1654029818e24d46144a562 -->
Hi @polchernikova-w — just a friendly reminder that this pull request is waiting on you. The dashboard status comment has the open items and is kept current.
/dashboard route:reviewers.<!-- pull-request-dashboard-author-nudge-completed:783d24a4c1654029818e24d46144a562 -->
_Outdated as of 2026-11-26 02:43 UTC: this reminder no longer reflects the current dashboard state. Check the dashboard status comment to see whether action is needed._
Left a couple inline comments on metric attribute cardinality and missing status/transport labels.
> Two PR-level questions:
>a2a.protocol.binding: I saw this was moved out to #612 (+1 on Option 1 there). Sincea2a..operation. has nohttp.,rpc., ornetwork.attributes, there's currently no way to break down latency, errors, or active operations by binding (JSONRPCvsHTTP+JSONvsGRPC). Could we either keepa2a.protocol.bindinghere or make sure #612 adds it to these four metrics too?
* Area2a.{client,server}.{request,response}.sizehistograms (similar tomcp.{client,server}.{request,response}.sizein #600) planned in the followup? Tracking payload sizes would be very useful since large task contexts and artifacts directly consume the caller's LLM context window.
Thanks a lot!
1. As for protocol binding attribute, I think https://github.com/open-telemetry/semantic-conventions-genai/issues/612 discusses and covers both spans and metrics. It talks about spans only because metrics are not in the repo now.
2. I think these belong to the transport layer (HTTP or gRPC), not to A2A
<!-- ccr-overview-v2 -->
🟡 Changes recommended
Non-streaming paths finalize server metrics before sending responses, contradicting the model’s transmission-based endpoint and excluding slow sends that streaming measurements include.
<details open>
<summary><strong>1 open issue</strong></summary>
</details>
<sub>Review effort: Balanced</sub>
<!-- ccr-overview-v2 -->
🔵 Needs a closer look
Human assessment is needed because span-only conformance expectations leave the four new A2A metrics outside missing-telemetry checks.
No open issues 🎉
<details>
<summary><strong>1 resolved since last review</strong></summary>
</details>
<sub>Review effort: Balanced</sub>
polchernikova-w
Description
Adds operation metrics for the Agent2Agent (A2A) protocol, following the A2A
spans added in #195.
From metrics, this PR covers operation metrics only: duration and in-flight count of A2A
operations on the client and the server. Streaming metrics (events sent and
received per stream) and task-lifecycle metrics (task state transitions, time
spent in a state, task events) will follow in separate PRs.
It also adds
a2a.operation.return_immediatelyto the A2A spans, sospans and duration metrics share the same
SendMessageattributes.Part of #254 (#254 stays open for the remaining metrics).
Defines:
| Metric | Instrument | Unit |
| --- | --- | --- |
|
a2a.client.operation.duration| Histogram |s||
a2a.server.operation.duration| Histogram |s||
a2a.client.operation.active| UpDownCounter |{operation}||
a2a.server.operation.active| UpDownCounter |{operation}|Metric attributes:
a2a.method.name(required) anda2a.protocol.versionon all four metrics.error.typeand the newa2a.operation.return_immediately(SendMessageonly) on the duration metrics,a2a.clientanda2a.serverspans and thea2a.http.server/a2a.grpc.serverrefinements.server.addressandserver.porton client metrics.The duration windows match the
a2a.clientanda2a.serverspans:until the response is received or produced for non-streaming calls, and until
the last stream event is consumed or sent for streaming calls, or until the operation
ends with an error. Active operations use the same start and end points. When reported alongside an
a2a.clientspan, the client duration SHOULD equal the span duration.error.typereuses the A2A error guidance from #195: the A2A error reason whenavailable (for example
TASK_NOT_FOUND), then the binding error code, then theexception name. To share it between spans and metrics, it moves into a new
internal
a2a.error.attributesgroup. The generated span docs are unchanged.New attributes
a2a.operation.return_immediately(boolean): maps toSendMessageConfiguration.returnImmediately. A non-blockingSendMessagereturns in milliseconds, while a blocking one waits for a terminal or
interrupted task state, which can take minutes. Without this attribute,
SendMessageduration percentiles mix the two kinds of call, and a span givesno indication why it is short or long. It is recorded on the duration metrics
and on the A2A spans. It is conditionally required only when the value is
true; when missing, the value is assumed to befalse(the protocol default),following the pattern of
messaging.destination.temporaryandmessaging.kafka.message.tombstone.Naming
operation.duration(rather thanrequest.duration) followsmcp.client.operation.duration/mcp.server.operation.durationin thisrepository. It measures the logical A2A operation, which can span several
transport requests (retries) or a whole response stream. That keeps it separate
from
http..request.durationand the RPC transport metrics, which stay thesource of truth for transport-level questions. A2A metrics can't be expressed by
adding attributes to transport metrics, because A2A instrumentation can't add
attributes to measurements recorded by HTTP or gRPC instrumentation. With
JSON-RPC, every method also shares one route, and A2A errors often arrive with
HTTP 200.
Motivation
User journey: incident triage and capacity planning for agent-to-agent
traffic. These metrics answer:
which A2A error?
SendMessagecalls take, measured separately.(saturation, stuck streams)?
Spans give per-call detail but are usually sampled. Metrics give unsampled
rates, latency distributions, and saturation that dashboards and alerts depend on.
Prior art:
mcp..operation.duration).active_requestspattern in the HTTP conventions (http.server.active_requests).Prototype
reference/scenarios/a2a-python/(a2a-sdk[http-server]==1.0.3) now recordsall four metrics alongside the existing spans, using real SDK clients and server
components:
HTTP-enriched servers) and REST
GetTaskhandler, so both theJSONRPCandHTTP+JSONbindings are exercised. Timing runs from handler entry to responseproduced, or to the last event yielded for streams.
SendMessage,SendStreamingMessage, andGetTaskwrap real SDKcalls. Streaming duration ends after the last event is consumed.
- The protocol version comes from the Agent Card interface.
-
a2a.operation.return_immediatelyis set from the request'sSendMessageConfigurationonly when it istrue. The scenario adds anon-blocking
SendMessagecall to cover it on the client and server spansand duration metrics.
-
error.typecomes from the protocol error. On the client it comes from theSDK's
A2A_ERROR_REASONSmapping.TASK_NOT_FOUNDis recorded ona2a.client.operation.durationand on thea2a.clientspan, which also fills the client-spanerror.typegap left in#195. The server error cases cover JSON-RPC (HTTP 200) and HTTP+JSON (HTTP 404).
at each call site.
Validation:
make check-policies,make generate-all(no drift),make test-json-schemas,make package-dev, Ruff,uv run run-scenario a2a-python --strict(no findings),uv run update-reports(no drift), and a link check on the changed docs.
Checklist
changelog.d/<pr-number>.enhancement.mdSee CONTRIBUTING.md.