You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/samplers/README.md
+12-9Lines changed: 12 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ The New Relic agent supports a robust sampling decision making interface. This i
4
4
5
5
## Config
6
6
7
-
Customers configure how they would like their transactions to be sampled under our `distributed_tracing` section in our config. Remember, sampling will only apply if a customer has `distributed_tracing.enabled` set to `true`.
7
+
Customers configure how they would like their transactions to be sampled under our `distributed_tracing` section in our config. Remember, sampling will only apply if a customer has `distributed_tracing.enabled` set to `true`, `distributed_tracing.sampler.full_granularity.enabled = true`, and if they want partial granularity traces, `distributed_tracing.sampler.partial_granularity.enabled = true`.
8
8
9
9
### Types
10
10
@@ -13,10 +13,13 @@ Customers configure how they would like their transactions to be sampled under o
13
13
-`root`: This is the main sampler for traces originating from the current service.
14
14
-`remote_parent_sampled`: The sampler for when the upstream service has sampled the trace.
15
15
-`remote_parent_not_sampled`: The sampler for when the upstream service has not sampled the trace.
16
+
-`SAMPLER_TYPE` can be `adaptive`, `always_on`, `always_off`, and `trace_id_ratio_based`.
17
+
-`SAMPLER_SUBOPTION` is only valid for `adaptive` and `trace_id_ratio_based` and only required for `trace_id_ratio_based`. `adaptive` will fall back to a global `AdaptiveSampler` with a sampling target defined by `distributed_tracing.sampler.adaptive_sampling_target` if `adaptive.sampling_target` is not given.
16
18
17
19
NOTE: `distributed_tracing.sampler` will be used as the setting for the full granularity samplers.
18
20
19
21
### Full Config in Accordance to Spec
22
+
Full Config in Accordance to Pending Spec Changes (as of agent team discussions, 11/21/2025):
20
23
21
24
```yaml
22
25
...
@@ -30,12 +33,12 @@ distributed_tracing:
30
33
exclude_newrelic_header: boolean (default false)
31
34
enable_success_metrics (OPTIONAL): boolean (default true, set to false to disable supportability metrics)
32
35
sampler: (section for sampling config options for different scenarios)
33
-
adaptive_sampling_target (see note on Sampling Target below)
36
+
adaptive_sampling_target (see note on Sampling Target above)
34
37
root: (when the trace originates from the current service)
35
-
${SAMPLER_TYPE} (See `Sampler Options` below)
38
+
${SAMPLER_TYPE} (See `Sampler Options` above)
36
39
${SAMPLER_SUBOPTION}
37
40
remote_parent_sampled: (when the upstream service has sampled the trace)
38
-
${SAMPLER_TYPE} (See `Sampler Options` below)
41
+
${SAMPLER_TYPE})
39
42
${SAMPLER_SUBOPTION}
40
43
remote_parent_not_sampled: (when the upstream service has not sampled the trace)
41
44
${SAMPLER_TYPE}
@@ -46,10 +49,10 @@ distributed_tracing:
46
49
enabled
47
50
type ("reduced", "essential", "compact")
48
51
root: (when the trace originates from the current service)
49
-
${SAMPLER_TYPE} (See `Sampler Options` below)
52
+
${SAMPLER_TYPE}
50
53
${SAMPLER_SUBOPTION}
51
54
remote_parent_sampled: (when the upstream service has sampled the trace)
52
-
${SAMPLER_TYPE} (See `Sampler Options` below)
55
+
${SAMPLER_TYPE}
53
56
${SAMPLER_SUBOPTION}
54
57
remote_parent_not_sampled: (when the upstream service has not sampled the trace)
55
58
${SAMPLER_TYPE}
@@ -59,9 +62,9 @@ distributed_tracing:
59
62
60
63
## Solution
61
64
62
-
There are three sampler modes, each with three sampler sections, resulting in potentially nine different sampling decisions that the agent would have to support. We create a new `Sampler` instance (`AdaptiveSampler`, `AlwaysOnSampler`, `AlwaysOffSampler`, or `TraceIdRatioBasedSampler`, defined in this folder) for each of these sampler modes' sections.
65
+
There are two sampler modes, each with three sampler sections, resulting in potentially six different sampling decisions that the agent would have to support. We create a new `Sampler` instance (`AdaptiveSampler`, `AlwaysOnSampler`, `AlwaysOffSampler`, or `TraceIdRatioBasedSampler`, defined in this folder) for each of these sampler modes' sections.
63
66
64
-
`agent.sampler`would be defined as:
67
+
`agent.sampler`is defined as:
65
68
66
69
*`agent.sampler.root`
67
70
*`agent.sampler.remoteParentSampled`
@@ -72,4 +75,4 @@ There are three sampler modes, each with three sampler sections, resulting in po
72
75
73
76
These samplers have a `applySamplingDecision({transaction})` function, which `Transaction` calls (in `lib/transaction/index.js`) to update its `sampled` field and therefore its `priority`.
74
77
75
-
Unlike the other samplers, the `AdaptiveSampler` must share state with other `AdaptiveSamplers` with the same `sampling_target`, which complicates our seperate sampler instances approach. This will be fixed shortly, and this document will be updated to describe that solution.
78
+
Unlike the other samplers, the `AdaptiveSampler` must share state with other `AdaptiveSampler`s if they do not have their suboption, `sampling_target,` defined. Thus, this introduces our seventh field on `agent.sampler.*`: `agent.sampler._globalAdaptiveSampler `. The intent of this field is to have one instance of an `AdaptiveSampler` for `adaptive` sampler sections that do not specify an `adaptive.sampling_target` to share.
0 commit comments