Skip to content

Emit rum.session_id as multi-value tags, capped at 10#43

Open
r1viollet wants to merge 1 commit into
mainfrom
r1viollet/rum-session-view-tags
Open

Emit rum.session_id as multi-value tags, capped at 10#43
r1viollet wants to merge 1 commit into
mainfrom
r1viollet/rum-session-view-tags

Conversation

@r1viollet

Copy link
Copy Markdown
Collaborator

Summary

  • Adds rum.session_id:<uuid> profile-level tags, one entry per completed session record produced during the profile window. Repeated entries with the same key (the standard Datadog multi-value facet shape — not comma-joined, not a JSON list) so each session id is independently queryable as @rum.session_id:<uuid>.
  • Placed alongside rum.application_id in PrepareAdditionalTags. Reuses the existing AddSingleTag push helper. Both rum.* tags now live in the same code region (ProfileExporter.cpp:1592-1620).
  • Cardinality capped at MAX_RUM_SESSION_ID_TAGS = 10 to bound tag indexing cost on pathological session-rotation patterns. Overflow logs Log::Warn reporting how many ids were skipped; the full id list still travels in optional_internal_metadata_json (rum_session_ids), unaffected by the cap.
  • Records are 1:1 with sessions by construction (Profiler::CompleteCurrentSession pushes once per session and clears _currentSessionId), so no dedup is needed in the collection step.

Implementation notes

Tag-list construction is factored into a pure static helper ProfileExporter::BuildRumTags(applicationId, sessionIds) -> vector<pair<string,string>>. ddog_Tag is opaque, so we can't inspect entries back out of ddog_Vec_Tag after pushing — pinning the contract upstream of the push is the only way to write meaningful unit tests.

Export() mirrors the session ids that already feed optional_internal_metadata_json into a separate rumSessionIds vector before clearing _sessionRecordsBuffer, then threads that vector down through ExportProfile to PrepareAdditionalTags.

Out of scope

The customData["view.id"] array (matching the chrome SDK contract for the runtime view-filter endpoint) and the optional_info_json channel are intentionally not in this PR.

Test plan

Unit tests in ProfileExporterTests.cpp:

  • empty input → empty list
  • application id only → 1 entry (regression for the existing rum.application_id emit)
  • 1 session, 3 sessions → N+1 entries (multi-value-facet shape)
  • empty applicationId → only session entries
  • empty session ids in the list are skipped

Manual on Windows (r1viollet):

  • Scenario 5 single run: pprof shows 2 rum.session_id:<uuid> entries — one auto-gen'd, one 99999999-...
  • Scenario 5 with 11 forced extra rotations (now removed from the runner): pprof shows exactly 10 rum.session_id:<uuid> entries; profiler log contains rum.session_id tag cap reached (10); N session id(s) from this export not emitted as tags

🤖 Generated with Claude Code

For each completed session record produced during the profile window,
emit a `rum.session_id:<uuid>` tag entry alongside the existing
`rum.application_id` tag. Repeated entries with the same key are the
standard Datadog convention for multi-value facets, so each session id
becomes independently queryable.

Cardinality is capped at MAX_RUM_SESSION_ID_TAGS (10) to bound tag
indexing cost on pathological session-rotation patterns. When the cap
is hit, Log::Warn reports how many ids were skipped; the full id list
is still embedded in optional_internal_metadata_json.

Tag-list construction is factored into a pure static helper
ProfileExporter::BuildRumTags so it's unit-testable -- ddog_Tag is opaque
and we can't read entries back out of ddog_Vec_Tag, so the contract has
to be pinned upstream of the push.

Tests in ProfileExporterTests.cpp cover:
* empty input -> empty list
* application id only -> 1 entry (regression for the existing tag emit)
* 1 session, 3 sessions -> 1 + N entries
* empty applicationId -> only session entries
* empty session ids in the list are skipped

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@r1viollet
r1viollet marked this pull request as ready for review May 6, 2026 10:28
@r1viollet
r1viollet requested a review from chrisnas as a code owner May 6, 2026 10:28
@r1viollet

Copy link
Copy Markdown
Collaborator Author

We discussed this.
This will help with long term approach. I think we can still consider it.
Short term we can focus more on having metrics associated to profiles to help with the filtering.

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.

2 participants