Add Root sampler, Trace ID ratio based sampler options#3330
Merged
kaylareopelle merged 29 commits intodevfrom Nov 21, 2025
Merged
Add Root sampler, Trace ID ratio based sampler options#3330kaylareopelle merged 29 commits intodevfrom
kaylareopelle merged 29 commits intodevfrom
Conversation
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.
Contributor
SimpleCov Report
|
kaylareopelle
commented
Nov 15, 2025
This was referenced Nov 15, 2025
hannahramadan
previously approved these changes
Nov 20, 2025
Co-authored-by: Hannah Ramadan <76922290+hannahramadan@users.noreply.github.com>
…/newrelic/newrelic-ruby-agent into trace-ratio-with-config-refactor
The method is used to determine priorities outside of the adaptive sampler and is the legacy, default priority
…/newrelic/newrelic-ruby-agent into trace-ratio-with-config-refactor
hannahramadan
approved these changes
Nov 21, 2025
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.
adaptiveoption to all DT samplersdefault,adaptive,trace_id_ratio_based,always_on,always_offCloses #3284
Extends #3307