feat(llmobs): auto-tag spans with session/user from RUM OTel baggage#17701
Draft
Kyle-Verhoog wants to merge 1 commit intomainfrom
Draft
feat(llmobs): auto-tag spans with session/user from RUM OTel baggage#17701Kyle-Verhoog wants to merge 1 commit intomainfrom
Kyle-Verhoog wants to merge 1 commit intomainfrom
Conversation
When the RUM browser SDK's `propagateTraceBaggage` option is enabled, it injects `session.id`, `user.id`, and `account.id` as OTel baggage on outbound requests. LLMObs spans now read these values from the active trace context and auto-apply them as `session_id`, `usr.id`, and `usr.account_id` (Datadog standard attributes), enabling RUM → LLMObs correlation without any manual `LLMObs.annotate()` calls. Explicit values set via `LLMObs.annotate()` continue to take precedence over baggage-derived values. MLOB-7332 Co-Authored-By: Claude Opus 4.7 (1M context) <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.
Description
When the RUM browser SDK's
propagateTraceBaggageoption is enabled, it injectssession.id,user.id, andaccount.idas OTel baggage on outbound requests. LLMObs spans now read these values from the active trace context and auto-apply them assession_id,usr.id, andusr.account_id(Datadog standard attributes) on the LLMObs span event, enabling RUM → LLMObs correlation without any manualLLMObs.annotate()calls.Explicit values set via
LLMObs.annotate()continue to take precedence over baggage-derived values.Jira: MLOB-7332 (parent epic MLOB-7330)
Testing
tests/llmobs/test_llmobs_service.py:test_rum_baggage_auto_tags_session_and_user— all three keys presenttest_rum_baggage_does_not_overwrite_explicit_session_idtest_rum_baggage_does_not_overwrite_annotated_user_tagtest_rum_baggage_partial_keys_only_tags_what_is_presentsession_id,experiment_baggage, andtagspatterns — 66 related tests pass.ruffformat +mypytyping clean.Risks
Low. The change is additive — LLMObs spans previously ignored baggage, so no existing behavior is overwritten. The baggage fallback only applies when no explicit value is set, so customers currently using
LLMObs.annotate(session_id=...)see no difference.The implementation slots into the same
_llmobs_tagsfunction that already reads experiment baggage (EXPERIMENT_ID_KEY, etc.), using the same pattern.Additional Notes
This is the first of a multi-repo series tracked under MLOB-7330:
usr.id / usr.account_idtoLlmObsFacets.javaso the tags become queryable@usr.*in LLMObs filter UIRUM baggage keys were verified against
browser-sdk/packages/rum-core/src/domain/tracing/tracer.ts:208-229. Note: RUM does not propagateuser.nameoruser.email— onlyuser.id+account.id— so those two are not in scope for auto-tagging.Claude session:
ff51fe11-3672-4ff3-924f-9595500003ddResume:
claude --resume ff51fe11-3672-4ff3-924f-9595500003dd