Skip to content

RUM-12495: Support trace sampling based on Session Id#169

Merged
ambushwork merged 1 commit into
developfrom
yl/trace-sampling-on-session
Jun 1, 2026
Merged

RUM-12495: Support trace sampling based on Session Id#169
ambushwork merged 1 commit into
developfrom
yl/trace-sampling-on-session

Conversation

@ambushwork

Copy link
Copy Markdown
Member

What does this PR do?

Previously, each HTTP request through DdUrlTransfer made an independent random sampling decision, so two requests in the same session could get different decisions.

This change makes trace sampling deterministic per-session: the last 48 bits of the session UUID are used as a seed for the same Knuth multiplicative hash (× 1111111111111111111) used by the Android and iOS SDKs. Requests in the same session now always receive the same sampling decision, consistent with backend expectations.

When no active session is present, the previous random fallback is preserved.

Note on implementation: BrightScript's LongInteger * does not wrap on 64-bit overflow — it uses double arithmetic for large products. The Knuth multiplication is therefore implemented via 16-bit chunk decomposition to stay within safe integer range, then assembled as a double for the threshold comparison.

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

@ambushwork
ambushwork force-pushed the yl/trace-sampling-on-session branch from f23f89a to b231162 Compare June 1, 2026 06:21
@ambushwork
ambushwork marked this pull request as ready for review June 1, 2026 06:22
@ambushwork
ambushwork requested a review from a team as a code owner June 1, 2026 06:22
Comment thread library/source/wrapper/DdUrlTransfer.bs Outdated
Comment thread test/source/tests/Test__DdUrlTransfer.bs
@ambushwork
ambushwork force-pushed the yl/trace-sampling-on-session branch from b231162 to eaa743a Compare June 1, 2026 11:05
@datadog-official

This comment has been minimized.

@ambushwork
ambushwork requested a review from kikoveiga June 1, 2026 11:13
@ambushwork
ambushwork force-pushed the yl/trace-sampling-on-session branch from eaa743a to 868d0ef Compare June 1, 2026 11:56
Comment thread library/source/wrapper/DdUrlTransfer.bs Outdated
@ambushwork
ambushwork force-pushed the yl/trace-sampling-on-session branch from 868d0ef to 679ac9a Compare June 1, 2026 15:56
@ambushwork
ambushwork force-pushed the yl/trace-sampling-on-session branch from 679ac9a to 1078724 Compare June 1, 2026 16:07
@ambushwork
ambushwork requested a review from kikoveiga June 1, 2026 16:07
@ambushwork
ambushwork merged commit 3ea48b4 into develop Jun 1, 2026
8 checks passed
@ambushwork
ambushwork deleted the yl/trace-sampling-on-session branch June 1, 2026 16:56
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