Skip to content

feat(go-adk): propagate A2A message metadata as OTEL span attributes#1737

Open
mesutoezdil wants to merge 3 commits intokagent-dev:mainfrom
mesutoezdil:feat/a2a-metadata-otel-span
Open

feat(go-adk): propagate A2A message metadata as OTEL span attributes#1737
mesutoezdil wants to merge 3 commits intokagent-dev:mainfrom
mesutoezdil:feat/a2a-metadata-otel-span

Conversation

@mesutoezdil
Copy link
Copy Markdown
Contributor

Closes #1734

Scalar values from the A2A message.metadata map are now set as attributes on the invocation span under the prefix a2a.message.metadata.<key>. Non-scalar values (nested objects, lists) are silently skipped so attributes stay flat and filterable in any OTEL backend.

This is useful for human-in-the-loop and external-trigger workflows where the caller needs to attach contextual data to a trace. A common case is an approval flow where a Slack bot sends back the approver identity via message/send and that identity needs to appear in audit traces without running a completely separate observability pipeline.

The call happens on the already-active invocation span, right after StartInvocationSpan, so all child spans (tool calls, LLM calls) are nested under the same root and the metadata is visible across the full trace.

Supported types: string, bool, float64, int, int64. Everything else is ignored.

Tests cover the normal path (string, bool, float64), the nil/empty-map no-op case, and that nested maps and lists are not forwarded.

Signed-off-by: mesutoezdil mesudozdil@gmail.com

Scalar values (string, bool, number) from the A2A message Metadata field
are now set as attributes on the invocation span under the prefix
a2a.message.metadata.<key>. Non-scalar values such as nested objects and
lists are skipped to keep attributes flat and filterable.

This lets callers attach contextual data to traces without a separate
observability pipeline. A common case is human-in-the-loop approval
flows where the approver identity is passed back via message/send and
needs to appear in audit traces.

Closes kagent-dev#1734

Signed-off-by: mesutoezdil <mesudozdil@gmail.com>
Copilot AI review requested due to automatic review settings April 23, 2026 14:49
@github-actions github-actions Bot added the enhancement New feature or request label Apr 23, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Remove trailing switch comment that caused gofmt to report a formatting
error, trim 4-line doc comment to one line (conventions: max one short
line), and drop the call-site comment whose content is already expressed
by the function name.

Signed-off-by: mesutoezdil <mesudozdil@gmail.com>
@mesutoezdil mesutoezdil force-pushed the feat/a2a-metadata-otel-span branch from b898cbd to 534ebd3 Compare April 30, 2026 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Propagate A2A message metadata as OTEL span attribute

3 participants