Skip to content

Add Root sampler, Trace ID ratio based sampler options#3330

Merged
kaylareopelle merged 29 commits intodevfrom
trace-ratio-with-config-refactor
Nov 21, 2025
Merged

Add Root sampler, Trace ID ratio based sampler options#3330
kaylareopelle merged 29 commits intodevfrom
trace-ratio-with-config-refactor

Conversation

@kaylareopelle
Copy link
Contributor

  • Adds the trace id ratio based sampling options, along with ratio configs for each of those options
    • This sampling matches the OpenTelemetry Ruby SDK sampler and not the recently defined algorithm that will be used for the Probability Sampler
  • Adds the adaptive option to all DT samplers
  • Adds the ability to configure the root sampling decision to the same options as the remote parent samplers: default, adaptive, trace_id_ratio_based, always_on, always_off

Closes #3284
Extends #3307

We have the allowlist functionality now that is faster.
default, adaptive, always_on, always_off are now available for use when
a trace is root, remote_parent_sampled or remote_parent_not_sampled.

default is first in the case list because it is the most common. I
predict adaptive will be far less common than always_on or always_off,
so I put it last for a slight performance benefit.
Move validation to a separate module and use a transform to call those
methods.

Remove ratio validation checks and fallbacks in Transaction,
TraceContext, and DistributedTracing.
Since both DistributedTracing#set_priority_and_sampled_newrelic_header
and TraceContext#set_priority_and_sampled are included in the
Transaction class and the methods ended up being identical, we can
define it in only one spot.
Setting it to all or nothing isn't compatible with the spec
Now the trace ratio sampling logic lives in one method
OpenTelemetry stores their trace IDs as binary strings:
"\xAB\xCD\xEF\x01#Eg\x89"
We keep ours as alphanumeric strings (ex: "abcdef0123456789")

Rather than coerce every trace ID into a binary string, we can use
Integer to translate our guids into the same value as the
unpacked binary by translating them into base 16.
@github-actions
Copy link
Contributor

SimpleCov Report

Coverage Threshold
Line 93.69% 93%

hannahramadan
hannahramadan previously approved these changes Nov 20, 2025
kaylareopelle and others added 2 commits November 21, 2025 10:08
Co-authored-by: Hannah Ramadan <76922290+hannahramadan@users.noreply.github.com>
@kaylareopelle kaylareopelle merged commit 1e6637b into dev Nov 21, 2025
45 checks passed
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.

Implement Trace ID Ratio-Based Sampler

3 participants

Comments