Skip to content

feat(llmobs): auto-tag spans with session/user from RUM OTel baggage#17701

Draft
Kyle-Verhoog wants to merge 1 commit intomainfrom
kyle.verhoog/llmobs-rum-baggage-auto-tag
Draft

feat(llmobs): auto-tag spans with session/user from RUM OTel baggage#17701
Kyle-Verhoog wants to merge 1 commit intomainfrom
kyle.verhoog/llmobs-rum-baggage-auto-tag

Conversation

@Kyle-Verhoog
Copy link
Copy Markdown
Member

@Kyle-Verhoog Kyle-Verhoog commented Apr 23, 2026

Description

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) on the LLMObs span event, enabling RUM → LLMObs correlation without any manual LLMObs.annotate() calls.

Explicit values set via LLMObs.annotate() continue to take precedence over baggage-derived values.

Jira: MLOB-7332 (parent epic MLOB-7330)

Testing

  • 4 new unit tests in tests/llmobs/test_llmobs_service.py:
    • test_rum_baggage_auto_tags_session_and_user — all three keys present
    • test_rum_baggage_does_not_overwrite_explicit_session_id
    • test_rum_baggage_does_not_overwrite_annotated_user_tag
    • test_rum_baggage_partial_keys_only_tags_what_is_present
  • Ran local regression across session_id, experiment_baggage, and tags patterns — 66 related tests pass.
  • ruff format + mypy typing 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_tags function 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:

  • dd-trace-js (MLOB-7334) — same change in Node.js tracer
  • logs-backend (MLOB-7333) — add usr.id / usr.account_id to LlmObsFacets.java so the tags become queryable
  • web-ui (MLOB-7335) — expose @usr.* in LLMObs filter UI
  • documentation (MLOB-7336) — docs update

RUM baggage keys were verified against browser-sdk/packages/rum-core/src/domain/tracing/tracer.ts:208-229. Note: RUM does not propagate user.name or user.email — only user.id + account.id — so those two are not in scope for auto-tagging.

Claude session: ff51fe11-3672-4ff3-924f-9595500003dd
Resume: claude --resume ff51fe11-3672-4ff3-924f-9595500003dd

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>
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.

1 participant