Skip to content

Commit 0840324

Browse files
feat: Add adaptive_sampling_target to config (#3406)
1 parent 4fa645b commit 0840324

File tree

3 files changed

+26
-11
lines changed

3 files changed

+26
-11
lines changed

lib/config/default.js

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,16 +1156,27 @@ defaultConfig.definition = () => {
11561156
},
11571157

11581158
sampler: {
1159-
/**
1160-
* When set to `always_on`, the sampled flag in the `traceparent` header
1161-
* being set to "true" will result in the local transaction being sampled
1162-
* with a priority value of "2". When set to `always_off`, the local
1163-
* transaction will never be sampled. At the default setting, the sampling
1164-
* decision will be determined according to the normal algorithm.
1165-
*
1166-
* This setting takes precedence over the `remote_parent_not_sampled`
1167-
* setting.
1168-
*/
1159+
/**
1160+
* The sampling target for adaptive sampling is controlled via this attribute when configuring the default/adaptive sampler.
1161+
* The default sampling target is 10 transactions/min when it is not specified but **MUST** be within the range of [1, 120] (inclusive).
1162+
* Upon agent connect, the connect response **MUST** provide the value of `sampling_target` based on this configuration setting's value.
1163+
* The `sampling_target` value from the connect response **SHOULD** be used as the sampling target value for adaptive sampling in the agent.
1164+
*/
1165+
adaptive_sampling_target: {
1166+
formatter: int,
1167+
default: 10
1168+
},
1169+
1170+
/**
1171+
* When set to `always_on`, the sampled flag in the `traceparent` header
1172+
* being set to "true" will result in the local transaction being sampled
1173+
* with a priority value of "2". When set to `always_off`, the local
1174+
* transaction will never be sampled. At the default setting, the sampling
1175+
* decision will be determined according to the normal algorithm.
1176+
*
1177+
* This setting takes precedence over the `remote_parent_not_sampled`
1178+
* setting.
1179+
*/
11691180
remote_parent_sampled: {
11701181
formatter: allowList.bind(null, ['always_on', 'always_off', 'default']),
11711182
default: 'default'

lib/config/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ function Config(config) {
123123
this.primary_application_id = null
124124
this.trusted_account_ids = null
125125
this.trusted_account_key = null
126-
this.sampling_target = 10
126+
this.sampling_target = this.distributed_tracing.sampler.adaptive_sampling_target
127127
this.sampling_target_period_in_seconds = 60
128128
this.max_payload_size_in_bytes = DEFAULT_MAX_PAYLOAD_SIZE_IN_BYTES
129129

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,10 @@ test('with default properties', async (t) => {
329329
assert.equal(configuration.distributed_tracing.sampler.remote_parent_not_sampled, 'default')
330330
})
331331

332+
await t.test('adaptive sampling target should default to 10 transactions/min', () => {
333+
assert.equal(configuration.distributed_tracing.sampler.adaptive_sampling_target, 10)
334+
})
335+
332336
await t.test('opentelemetry', () => {
333337
const otel = configuration.opentelemetry_bridge
334338
assert.equal(otel.enabled, false)

0 commit comments

Comments
 (0)