Skip to content

Commit 36d907f

Browse files
feat: Removed samplers under distributed_tracing.sampler.full_granularity.* (newrelic#3535)
1 parent ad63441 commit 36d907f

File tree

6 files changed

+12
-60
lines changed

6 files changed

+12
-60
lines changed

lib/config/default.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1173,7 +1173,6 @@ defaultConfig.definition = () => {
11731173
default: true,
11741174
formatter: boolean
11751175
},
1176-
...samplerConfigs
11771176
},
11781177
partial_granularity: {
11791178
enabled: {

lib/config/samplers.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
const { allowList, float } = require('./formatters')
88

99
/**
10-
* This configuration is currently the same for `distributed_tracing.sampler`,
11-
* `distributed_tracing.sampler.full_granularity` and `distributed_tracing.sampler.partial_granularity`
10+
* This configuration is currently the same for `distributed_tracing.sampler` and `distributed_tracing.sampler.partial_granularity`
1211
* Note: This also just defines the outer structure. These values are mixed data types. Most of the time
1312
* it is just a string. But if you want to use the `trace_id_ratio_based` sampler, then you need to
1413
* provide an object with a `ratio` property. All of that mapping is done in `lib/config/index.js`
@@ -112,12 +111,12 @@ function isTraceIdRatioBasedConfig(sampler, samplerConfig) {
112111
}
113112

114113
/**
115-
* Check if the sampler is a valid value of either 'sampler', 'full_granularity', or 'partial_granularity'
114+
* Check if the sampler is a valid value of either 'sampler' or 'partial_granularity'
116115
* @param {string} sampler - The sampler key to validate
117116
* @returns {boolean} true if valid, false otherwise
118117
*/
119118
function isValidDTSampler(sampler) {
120-
return ['sampler', 'full_granularity', 'partial_granularity'].includes(sampler)
119+
return ['sampler', 'partial_granularity'].includes(sampler)
121120
}
122121

123122
/**
@@ -151,7 +150,7 @@ function setTraceIdRatioSamplerFromEnv({ key, config, paths, setNestedKey, logge
151150

152151
const lastPath = paths[paths.length - 1]
153152
if (isValidDTSampler(lastPath) && isValidDTSamplerType(key)) {
154-
// Get the value of `config.distributed_tracing.sampler[key]` or `config.distributed_tracing.sampler.full_granularity[key]` or `config.distributed_tracing.sampler.partial_granularity[key]`
153+
// Get the value of `config.distributed_tracing.sampler[key]` or `config.distributed_tracing.sampler.partial_granularity[key]`
155154
const nestedValue = getNestedValue(config, [...paths, key])
156155
if (nestedValue !== 'trace_id_ratio_based') {
157156
return

lib/samplers/README.md

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ Customers configure how they would like their transactions to be sampled under o
88

99
### Types
1010

11-
- A "sampler mode" refers to the following config sections: `distributed_tracing.sampler`, `distributed_tracing.sampler.full_granularity`, and `distributed_tracing.sampler.partial_granularity`. They are defined by the three sections: `root`, `remote_parent_sampled`, and `remote_parent_not_sampled`.
11+
- A "sampler mode" refers to the following config sections: `distributed_tracing.sampler` and `distributed_tracing.sampler.partial_granularity`. They are defined by the three sections: `root`, `remote_parent_sampled`, and `remote_parent_not_sampled`.
1212
- A "sampler section" refers to `root`, `remote_parent_sampled`, or `remote_parent_not_sampled` within a particular sampler mode. The config defined at this section, i.e. `SAMPLER_TYPE: SAMPLER_SUBOPTION?`, describes the sampling decision for that particular scenario within that mode.
1313
- `root`: This is the main sampler for traces originating from the current service.
1414
- `remote_parent_sampled`: The sampler for when the upstream service has sampled the trace.
1515
- `remote_parent_not_sampled`: The sampler for when the upstream service has not sampled the trace.
1616

17-
NOTE: `distributed_tracing.sampler` only exists for backward compatiability and may be deprecated in favor of `distributed_tracing.sampler.full_granularity`. For now, `full_granularity` will take precedence over the old path.
17+
NOTE: `distributed_tracing.sampler` will be used as the setting for the full granularity samplers.
1818

1919
### Full Config in Accordance to Spec
2020

@@ -42,15 +42,6 @@ distributed_tracing:
4242
${SAMPLER_SUBOPTION}
4343
full_granularity:
4444
enabled
45-
root: (when the trace originates from the current service)
46-
${SAMPLER_TYPE} (See `Sampler Options` below)
47-
${SAMPLER_SUBOPTION}
48-
remote_parent_sampled: (when the upstream service has sampled the trace)
49-
${SAMPLER_TYPE} (See `Sampler Options` below)
50-
${SAMPLER_SUBOPTION}
51-
remote_parent_not_sampled: (when the upstream service has not sampled the trace)
52-
${SAMPLER_TYPE}
53-
${SAMPLER_SUBOPTION}
5445
partial_granularity:
5546
enabled
5647
type ("reduced", "essential", "compact")
@@ -72,18 +63,12 @@ There are three sampler modes, each with three sampler sections, resulting in po
7263

7364
`agent.sampler` would be defined as:
7465

75-
* `agent.sampler.fullGranularity.root`
76-
* `agent.sampler.fullGranularity.remoteParentSampled`
77-
* `agent.sampler.fullGranularity.remoteParentNotSampled`
78-
* `agent.sampler.partialGranularity.root`
79-
* `agent.sampler.partialGranularity.remoteParentSampled`
80-
* `agent.sampler.partialGranularity.remoteParentNotSampled`
81-
82-
These fields currently exist (before core tracing was implemented); `agent.sampler.fullGranularity.*` will take precedence over these fields:
83-
8466
* `agent.sampler.root`
8567
* `agent.sampler.remoteParentSampled`
8668
* `agent.sampler.remoteParentNotSampled`
69+
* `agent.sampler.partialGranularity.root`
70+
* `agent.sampler.partialGranularity.remoteParentSampled`
71+
* `agent.sampler.partialGranularity.remoteParentNotSampled`
8772

8873
These samplers have a `applySamplingDecision({transaction})` function, which `Transaction` calls (in `lib/transaction/index.js`) to update its `sampled` field and therefore its `priority`.
8974

test/unit/config/config-defaults.test.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,6 @@ test('with default properties', async (t) => {
335335
adaptive_sampling_target: 10,
336336
full_granularity: {
337337
enabled: true,
338-
root: 'default',
339-
remote_parent_sampled: 'default',
340-
remote_parent_not_sampled: 'default'
341338
},
342339
partial_granularity: {
343340
enabled: false,

test/unit/config/config-env.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,9 @@ test('when overriding configuration values via environment variables', async (t)
188188
})
189189
})
190190

191-
const samplers = ['SAMPLER', 'SAMPLER_FULL_GRANULARITY', 'SAMPLER_PARTIAL_GRANULARITY']
191+
const samplers = ['SAMPLER', 'SAMPLER_PARTIAL_GRANULARITY']
192192
for (const samplerName of samplers) {
193-
const key = samplerName === 'SAMPLER_FULL_GRANULARITY' ? 'full_granularity' : 'partial_granularity'
193+
const key = samplerName === 'SAMPLER' ? 'sampler' : 'partial_granularity'
194194
const samplerTypes = ['root', 'remote_parent_sampled', 'remote_parent_not_sampled']
195195
for (const type of samplerTypes) {
196196
const envVar = type.toUpperCase()

test/unit/config/config.test.js

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ test('distributed tracing samplers', async (t) => {
245245
assert.equal(configuration.distributed_tracing.sampler.remote_parent_sampled, 'adaptive')
246246
})
247247

248-
const samplers = ['sampler', 'sampler.full_granularity', 'sampler.partial_granularity']
248+
const samplers = ['sampler', 'sampler.partial_granularity']
249249
const samplerTypes = ['root', 'remote_parent_sampled', 'remote_parent_not_sampled']
250250
for (const samplerName of samplers) {
251251
const name = samplerName.split('.')[1]
@@ -347,23 +347,6 @@ test('distributed tracing samplers', async (t) => {
347347
ratio: 0.85
348348
}
349349
},
350-
full_granularity: {
351-
root: {
352-
trace_id_ratio_based: {
353-
ratio: 0.6
354-
}
355-
},
356-
remote_parent_sampled: {
357-
trace_id_ratio_based: {
358-
ratio: 0.5
359-
}
360-
},
361-
remote_parent_not_sampled: {
362-
trace_id_ratio_based: {
363-
ratio: 0.4
364-
}
365-
}
366-
},
367350
partial_granularity: {
368351
root: {
369352
trace_id_ratio_based: {
@@ -389,9 +372,6 @@ test('distributed tracing samplers', async (t) => {
389372
assert.equal(configuration.distributed_tracing.sampler.root.trace_id_ratio_based.ratio, 0.5)
390373
assert.equal(configuration.distributed_tracing.sampler.remote_parent_sampled.trace_id_ratio_based.ratio, 0.6)
391374
assert.equal(configuration.distributed_tracing.sampler.remote_parent_not_sampled.trace_id_ratio_based.ratio, 0.85)
392-
assert.equal(configuration.distributed_tracing.sampler.full_granularity.root.trace_id_ratio_based.ratio, 0.6)
393-
assert.equal(configuration.distributed_tracing.sampler.full_granularity.remote_parent_sampled.trace_id_ratio_based.ratio, 0.5)
394-
assert.equal(configuration.distributed_tracing.sampler.full_granularity.remote_parent_not_sampled.trace_id_ratio_based.ratio, 0.4)
395375
assert.equal(configuration.distributed_tracing.sampler.partial_granularity.root.trace_id_ratio_based.ratio, 0.4)
396376
assert.equal(configuration.distributed_tracing.sampler.partial_granularity.remote_parent_sampled.trace_id_ratio_based.ratio, 0.5)
397377
assert.equal(configuration.distributed_tracing.sampler.partial_granularity.remote_parent_not_sampled.trace_id_ratio_based.ratio, 0.6)
@@ -404,11 +384,6 @@ test('distributed tracing samplers', async (t) => {
404384
root: 'always_on',
405385
remote_parent_sampled: 'default',
406386
remote_parent_not_sampled: 'adaptive',
407-
full_granularity: {
408-
root: 'always_off',
409-
remote_parent_sampled: 'adaptive',
410-
remote_parent_not_sampled: 'always_on'
411-
},
412387
partial_granularity: {
413388
root: 'adaptive',
414389
remote_parent_sampled: 'always_on',
@@ -422,9 +397,6 @@ test('distributed tracing samplers', async (t) => {
422397
assert.equal(configuration.distributed_tracing.sampler.root, 'always_on')
423398
assert.equal(configuration.distributed_tracing.sampler.remote_parent_sampled, 'default')
424399
assert.equal(configuration.distributed_tracing.sampler.remote_parent_not_sampled, 'adaptive')
425-
assert.equal(configuration.distributed_tracing.sampler.full_granularity.root, 'always_off')
426-
assert.equal(configuration.distributed_tracing.sampler.full_granularity.remote_parent_sampled, 'adaptive')
427-
assert.equal(configuration.distributed_tracing.sampler.full_granularity.remote_parent_not_sampled, 'always_on')
428400
assert.equal(configuration.distributed_tracing.sampler.partial_granularity.root, 'adaptive')
429401
assert.equal(configuration.distributed_tracing.sampler.partial_granularity.remote_parent_sampled, 'always_on')
430402
assert.equal(configuration.distributed_tracing.sampler.partial_granularity.remote_parent_not_sampled, 'default')

0 commit comments

Comments
 (0)