feat(util-genai): auto-propagate common GenAI attributes via baggage#57
Merged
Merged
Conversation
startEntry / startInvokeAgent / startCreateAgent now publish the set gen_ai.agent.name / gen_ai.user.id / gen_ai.session.id into OpenTelemetry Baggage. GenAI child spans (LLM / Tool / ReAct Step / Embedding / Retrieval / Rerank / Memory) created under that Entry/Agent context automatically inherit these three common attributes — no need to set them on every child invocation. - Fill-only: a child field is backfilled only when unset, so explicit values win. - Only affects util-created GenAI spans; plain OTel SDK business spans are untouched. - Enables downstream (probe-created) spans to read the values from baggage. - New exported helpers setCommonBaggage / backfillCommonFromBaggage. - Remove a dead no-op context.with(...) in TelemetryHandler.startLlm. Bump to 0.1.0-beta.10. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.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.
Summary
Adds automatic propagation of the ARMS GenAI common attributes (
gen_ai.agent.name/gen_ai.user.id/gen_ai.session.id) via OpenTelemetry Baggage, matching the Pythonloongsuite-otel-util-genai0.6.1 behavior.startEntry/startInvokeAgent/startCreateAgentwrite the set common attributes into Baggage on the span'scontextToken.setCommonBaggage/backfillCommonFromBaggage.context.with(...)inTelemetryHandler.startLlm.0.1.0-beta.10.Test plan
npm run build(tsc) — cleannpm test— 19 files / 207 tests passing (incl. newbaggage-propagation.test.ts: child inheritance, explicit-wins, Entry propagation, no-baggage backward-compat)agent.name/user.id/session.idwithout being set explicitly; custom business spans correctly do NOT inherit🤖 Generated with Claude Code