Repository navigation
feat(go-adk): propagate A2A message metadata as OTEL span attributes - #1737
Merged
Merged
Conversation
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 #1734 Signed-off-by: mesutoezdil <mesudozdil@gmail.com>
6 tasks done
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>
moezdil
force-pushed
the
feat/a2a-metadata-otel-span
branch
from
April 30, 2026 14:19
b898cbd to
534ebd3
Compare
EItanya
approved these changes
May 7, 2026
rtemperini
added a commit
to rtemperini/kagent
that referenced
this pull request
Aug 28, 2026
Bring the Python runtimes to parity with the Go ADK. The Go runtime already reads A2A message metadata into span attributes (kagent-dev#1734, kagent-dev#1737); the Python runtimes ignored inbound metadata entirely, so agents on the Python runtime had no way to get caller identity onto their traces. Mirror the Go implementation exactly: the same KAGENT_TRACE_CONTEXT_KEYS allowlist, the same baggage-then-metadata precedence, the same limits, the same control character stripping, and the same kagent.context. namespace, so the two runtimes cannot drift. Values are merged into the request-scoped attribute bag that KagentAttributesSpanProcessor stamps onto every span. The ADK, LangGraph, and CrewAI executors all promote context through the shared helper. Reading a Message's protobuf Struct metadata moves into kagent.core.a2a.read_message_metadata rather than being repeated per package. Also assert that the OTel SDK's default propagator carries baggage: the Python runtime relies on that default rather than configuring a propagator, so an SDK change that dropped it would silently break the baggage path. Signed-off-by: Ricardo Temperini <29879569+rtemperini@users.noreply.github.com> Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1734
Scalar values from the A2A
message.metadatamap are now set as attributes on the invocation span under the prefixa2a.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/sendand 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