Skip to content

feat: add OpenTelemetry plugin with traces - #616

Merged
polchernikova-w merged 6 commits into
mainfrom
tracing-plugin
Nov 23, 2026
Merged

polchernikova-w merged 6 commits into
mainfrom
tracing-plugin

Conversation

@polchernikova-w

Copy link
Copy Markdown
Contributor

Description

Adds integrations/otel/a2aotel, an OpenTelemetry plugin for A2A clients and servers. It's built on a2aplugin and follows the A2A semantic convention.

This PR adds traces only. Metrics will come in a follow-up; the package layout leaves room for them.

handler := a2asrv.NewHandler(executor, a2asrv.WithPlugins(
	a2aotel.NewServerPlugin(a2aotel.WithAgentCard(card)),
))

client, err := a2aclient.NewFromCard(ctx, card, a2aclient.WithPlugins(a2aotel.NewClientPlugin()))

What it emits

Span Kind Name
a2a.client CLIENT {a2a.method.name}
a2a.server SERVER {a2a.method.name}

Attributes: a2a.method.name, a2a.protocol.version, a2a.tenant, a2a.message.id, a2a.message.reference_task_ids, a2a.operation.return_immediately, a2a.task.id, a2a.task.state, gen_ai.conversation.id, gen_ai.agent.{name,description,version}, error.type, and server.{address,port} on client spans.

Dependencies

Root go.mod now requires go.opentelemetry.io/otel, otel/trace and otel/sdk (tests only), all at v1.44.0. OTel was already in the module graph through gRPC at the same version, so SDK users don't get a higher OTel version.

Known limitations (follow-ups)

These need SDK changes and will be fixed in separate PRs:

  1. Client error.type for transport failures. Client transports turn responses without an A2A reason into sentinel errors based on the status code, so the original code is lost. For example, gRPC UNAVAILABLE is reported as INTERNAL_ERROR and HTTP 503 as SERVER_ERROR, while the spec wants the raw status code.
  2. Client a2a.tenant. The plugin can't see Config.DisableTenantPropagation or the tenant of the endpoint the client picked. It can report a context tenant that isn't sent, or miss an endpoint tenant when the client was created without a card.

Tests

  • Client and server unit tests
  • End-to-end JSON-RPC test

@polchernikova-w
polchernikova-w marked this pull request as ready for review November 18, 2026 18:04
Comment thread integrations/otel/a2aotel/client.go Resolved
Comment thread integrations/otel/a2aotel/attributes.go Resolved
Comment thread integrations/otel/a2aotel/server.go Resolved
Comment thread integrations/otel/a2aotel/server.go Resolved
@polchernikova-w
polchernikova-w added this pull request to the merge queue Nov 23, 2026
Merged via the queue into main with commit cac6958 Nov 23, 2026
5 checks passed
@polchernikova-w
polchernikova-w deleted the tracing-plugin branch November 23, 2026 15:10
sametakan29 pushed a commit to sametakan29/a2a-go that referenced this pull request Nov 29, 2026
a2aproject#632)

## Description

Part of a2aproject#631 (follow-up from a2aproject#616).

Previously, `a2aclient` filled in the request tenant inside
`tenantTransportDecorator`, which ran *after* plugins and interceptors.
Because of that, `a2aotel` had to guess the tenant on its own and could
not see `Config.DisableTenantPropagation` or the endpoint tenant when
the client was created without an `AgentCard`.

This PR moves tenant resolution into `Client.newRequest` so the tenant
is set on a copy of the request payload before plugins and interceptors
run:

- **`a2aclient`**: Resolve `req.Tenant` in `Client.newRequest`
(preserving the same priority: explicit request tenant → endpoint tenant
→ context tenant unless `DisableTenantPropagation` is set) without
modifying the caller's request struct, and remove
`tenantTransportDecorator`.
- **`integrations/otel/a2aotel`**: Remove `clientTenant` and read
`a2a.tenant` directly from the request payload.
sametakan29 pushed a commit to sametakan29/a2a-go that referenced this pull request Nov 29, 2026
…2aproject#633)

## Description

Closes a2aproject#631 (follow-up from a2aproject#616).

Previously, when a client transport received an error response without
an A2A `ErrorInfo` reason, it mapped the status code to an A2A sentinel
error and dropped the original code. The A2A semantic conventions expect
the raw status/error code instead.

Changes:
- **`a2a`**: Add `TransportCode` to `a2a.Error` for transport error
responses that have no A2A `ErrorInfo` reason.
- **`internal/grpcutil`**, **`internal/rest`**, **`internal/jsonrpc`**:
Populate `TransportCode` with the raw gRPC status name
(`"UNAVAILABLE"`), HTTP status code (`"503"`), or JSON-RPC error code
(`"-32001"`) when no A2A `ErrorInfo` (`domain == "a2a-protocol.org"`) is
present.
- **`integrations/otel/a2aotel`**: Return `a2aErr.TransportCode` in
`clientErrorType` when set.
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