Skip to content

Commit 601885d

Browse files
authored
feat: add config DD_RUNTIME_METRICS_RUNTIME_ID_ENABLED / remove experimental (#5865)
* Deprecate DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED for DD_RUNTIME_METRICS_RUNTIME_ID_ENABLED
1 parent cafe33b commit 601885d

File tree

4 files changed

+37
-18
lines changed

4 files changed

+37
-18
lines changed

packages/dd-trace/src/config.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,6 @@ class Config {
501501
this._setValue(defaults, 'env')
502502
this._setValue(defaults, 'experimental.enableGetRumData', false)
503503
this._setValue(defaults, 'experimental.exporter')
504-
this._setValue(defaults, 'experimental.runtimeId', false)
505504
this._setValue(defaults, 'flushInterval', 2000)
506505
this._setValue(defaults, 'flushMinSpans', 1000)
507506
this._setValue(defaults, 'gitMetadataEnabled', true)
@@ -565,6 +564,7 @@ class Config {
565564
this._setValue(defaults, 'remoteConfig.pollInterval', 5) // seconds
566565
this._setValue(defaults, 'reportHostname', false)
567566
this._setValue(defaults, 'runtimeMetrics', false)
567+
this._setValue(defaults, 'runtimeMetricsRuntimeId', false)
568568
this._setValue(defaults, 'sampleRate')
569569
this._setValue(defaults, 'sampler.rateLimit', 100)
570570
this._setValue(defaults, 'sampler.rules', [])
@@ -742,7 +742,7 @@ class Config {
742742
DD_TRACE_ENABLED,
743743
DD_TRACE_EXPERIMENTAL_EXPORTER,
744744
DD_TRACE_EXPERIMENTAL_GET_RUM_DATA_ENABLED,
745-
DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED,
745+
DD_RUNTIME_METRICS_RUNTIME_ID_ENABLED,
746746
DD_TRACE_GIT_METADATA_ENABLED,
747747
DD_TRACE_GLOBAL_TAGS,
748748
DD_TRACE_GRAPHQL_ERROR_EXTENSIONS,
@@ -865,7 +865,6 @@ class Config {
865865
this._setBoolean(env, 'traceEnabled', DD_TRACE_ENABLED)
866866
this._setBoolean(env, 'experimental.enableGetRumData', DD_TRACE_EXPERIMENTAL_GET_RUM_DATA_ENABLED)
867867
this._setString(env, 'experimental.exporter', DD_TRACE_EXPERIMENTAL_EXPORTER)
868-
this._setBoolean(env, 'experimental.runtimeId', DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED)
869868
if (AWS_LAMBDA_FUNCTION_NAME) this._setValue(env, 'flushInterval', 0)
870869
this._setValue(env, 'flushMinSpans', maybeInt(DD_TRACE_PARTIAL_FLUSH_MIN_SPANS))
871870
this._envUnprocessed.flushMinSpans = DD_TRACE_PARTIAL_FLUSH_MIN_SPANS
@@ -946,6 +945,7 @@ class Config {
946945
: undefined
947946
this._setBoolean(env, 'runtimeMetrics', DD_RUNTIME_METRICS_ENABLED ||
948947
otelSetRuntimeMetrics)
948+
this._setBoolean(env, 'runtimeMetricsRuntimeId', DD_RUNTIME_METRICS_RUNTIME_ID_ENABLED)
949949
this._setArray(env, 'sampler.spanSamplingRules', reformatSpanSamplingRules(coalesce(
950950
safeJsonParse(maybeFile(DD_SPAN_SAMPLING_RULES_FILE)),
951951
safeJsonParse(DD_SPAN_SAMPLING_RULES)
@@ -1100,7 +1100,7 @@ class Config {
11001100
this._setString(opts, 'env', options.env || tags.env)
11011101
this._setBoolean(opts, 'experimental.enableGetRumData', options.experimental?.enableGetRumData)
11021102
this._setString(opts, 'experimental.exporter', options.experimental?.exporter)
1103-
this._setBoolean(opts, 'experimental.runtimeId', options.experimental?.runtimeId)
1103+
this._setBoolean(opts, 'runtimeMetricsRuntimeId', options.runtimeMetricsRuntimeId)
11041104
this._setValue(opts, 'flushInterval', maybeInt(options.flushInterval))
11051105
this._optsUnprocessed.flushInterval = options.flushInterval
11061106
this._setValue(opts, 'flushMinSpans', maybeInt(options.flushMinSpans))
@@ -1149,6 +1149,7 @@ class Config {
11491149
}
11501150
this._setBoolean(opts, 'reportHostname', options.reportHostname)
11511151
this._setBoolean(opts, 'runtimeMetrics', options.runtimeMetrics)
1152+
this._setBoolean(opts, 'runtimeMetricsRuntimeId', options.runtimeMetricsRuntimeId)
11521153
this._setArray(opts, 'sampler.spanSamplingRules', reformatSpanSamplingRules(options.spanSamplingRules))
11531154
this._setUnit(opts, 'sampleRate', coalesce(options.sampleRate, options.ingestion.sampleRate))
11541155
const ingestion = options.ingestion || {}

packages/dd-trace/src/dogstatsd.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ class DogStatsDClient {
165165
.filter(key => {
166166
// Skip runtime-id unless enabled as cardinality may be too high
167167
if (key !== 'runtime-id') return true
168-
return (config.experimental && config.experimental.runtimeId)
168+
return config.runtimeMetricsRuntimeId
169169
})
170170
.forEach(key => {
171171
// https://docs.datadoghq.com/tagging/#defining-tags

packages/dd-trace/src/supported-configurations.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@
127127
"DD_REMOTE_CONFIGURATION_ENABLED": ["A"],
128128
"DD_RUNTIME_METRICS_ENABLED": ["A"],
129129
"DD_RUNTIME_METRICS_FLUSH_INTERVAL": ["A"],
130+
"DD_RUNTIME_METRICS_RUNTIME_ID_ENABLED": ["A"],
130131
"DD_SERVICE_MAPPING": ["A"],
131132
"DD_SERVICE": ["A"],
132133
"DD_SITE": ["A"],
@@ -238,7 +239,6 @@
238239
"DD_TRACE_EXPERIMENTAL_B3_ENABLED": ["A"],
239240
"DD_TRACE_EXPERIMENTAL_EXPORTER": ["A"],
240241
"DD_TRACE_EXPERIMENTAL_GET_RUM_DATA_ENABLED": ["A"],
241-
"DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED": ["A"],
242242
"DD_TRACE_EXPERIMENTAL_SPAN_COUNTS": ["A"],
243243
"DD_TRACE_EXPERIMENTAL_STATE_TRACKING": ["A"],
244244
"DD_TRACE_EXPRESS_ENABLED": ["A"],
@@ -427,6 +427,7 @@
427427
"DD_PROFILING_ENDPOINT_COLLECTION_ENABLED": ["DD_PROFILING_EXPERIMENTAL_ENDPOINT_COLLECTION_ENABLED"],
428428
"DD_PROFILING_TIMELINE_ENABLED": ["DD_PROFILING_EXPERIMENTAL_TIMELINE_ENABLED"],
429429
"DD_REMOTE_CONFIGURATION_ENABLED": ["DD_REMOTE_CONFIG_ENABLED" ],
430+
"DD_RUNTIME_METRICS_RUNTIME_ID_ENABLED": ["DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED"],
430431
"DD_SERVICE": ["DD_SERVICE_NAME"],
431432
"DD_TRACE_AGENT_URL": ["DD_TRACE_URL"]
432433
},
@@ -435,6 +436,7 @@
435436
"DD_PROFILING_EXPERIMENTAL_CPU_ENABLED": "DD_PROFILING_CPU_ENABLED",
436437
"DD_EXPERIMENTAL_PROFILING_ENABLED": "DD_PROFILING_ENABLED",
437438
"DD_PROFILING_EXPERIMENTAL_CODEHOTSPOTS_ENABLED": "DD_PROFILING_CODEHOTSPOTS_ENABLED",
438-
"DD_PROFILING_EXPERIMENTAL_TIMELINE_ENABLED": "DD_PROFILING_TIMELINE_ENABLED"
439+
"DD_PROFILING_EXPERIMENTAL_TIMELINE_ENABLED": "DD_PROFILING_TIMELINE_ENABLED",
440+
"DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED": "DD_RUNTIME_METRICS_RUNTIME_ID_ENABLED"
439441
}
440442
}

packages/dd-trace/test/config.spec.js

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,22 @@ describe('Config', () => {
113113
assert.strictEqual(warning.code, 'DATADOG_DD_PROFILING_EXPERIMENTAL_ENDPOINT_COLLECTION_ENABLED')
114114
})
115115

116+
it('should set new runtimeMetricsRuntimeId from deprecated DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED', async () => {
117+
process.env.DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED = 'true'
118+
assert.strictEqual(process.env.DD_RUNTIME_METRICS_RUNTIME_ID_ENABLED, undefined)
119+
const config = new Config()
120+
expect(config).to.have.property('runtimeMetricsRuntimeId', true)
121+
assert.strictEqual(getEnvironmentVariable('DD_RUNTIME_METRICS_RUNTIME_ID_ENABLED'), 'true')
122+
delete process.env.DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED
123+
124+
const [warning] = await once(process, 'warning')
125+
assert.strictEqual(warning.name, 'DeprecationWarning')
126+
assert.match(
127+
warning.message,
128+
/variable DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED .+ DD_RUNTIME_METRICS_RUNTIME_ID_ENABLED instead/
129+
)
130+
})
131+
116132
it('should pass through random envs', async () => {
117133
process.env.FOOBAR = 'true'
118134
const { FOOBAR } = getEnvironmentVariables()
@@ -261,6 +277,7 @@ describe('Config', () => {
261277
expect(config).to.have.nested.property('crashtracking.enabled', true)
262278
expect(config).to.have.property('sampleRate', undefined)
263279
expect(config).to.have.property('runtimeMetrics', false)
280+
expect(config).to.have.property('runtimeMetricsRuntimeId', false)
264281
expect(config.tags).to.have.property('service', 'node')
265282
expect(config).to.have.property('plugins', true)
266283
expect(config).to.have.property('traceEnabled', true)
@@ -286,7 +303,6 @@ describe('Config', () => {
286303
expect(config).to.have.nested.deep.property('tracePropagationStyle.inject', ['datadog', 'tracecontext', 'baggage'])
287304
expect(config).to.have.nested.deep.property('tracePropagationStyle.extract', ['datadog', 'tracecontext', 'baggage'])
288305
expect(config).to.have.nested.property('tracePropagationBehaviorExtract', 'continue')
289-
expect(config).to.have.nested.property('experimental.runtimeId', false)
290306
expect(config).to.have.nested.property('experimental.exporter', undefined)
291307
expect(config).to.have.nested.property('experimental.enableGetRumData', false)
292308
expect(config).to.have.nested.property('apmTracingEnabled', true)
@@ -373,7 +389,6 @@ describe('Config', () => {
373389
{ name: 'env', value: undefined, origin: 'default' },
374390
{ name: 'experimental.enableGetRumData', value: false, origin: 'default' },
375391
{ name: 'experimental.exporter', value: undefined, origin: 'default' },
376-
{ name: 'experimental.runtimeId', value: false, origin: 'default' },
377392
{ name: 'flushInterval', value: 2000, origin: 'default' },
378393
{ name: 'flushMinSpans', value: 1000, origin: 'default' },
379394
{ name: 'gitMetadataEnabled', value: true, origin: 'default' },
@@ -430,6 +445,7 @@ describe('Config', () => {
430445
{ name: 'reportHostname', value: false, origin: 'default' },
431446
{ name: 'reportHostname', value: false, origin: 'default' },
432447
{ name: 'runtimeMetrics', value: false, origin: 'default' },
448+
{ name: 'runtimeMetricsRuntimeId', value: false, origin: 'default' },
433449
{ name: 'sampleRate', value: undefined, origin: 'default' },
434450
{ name: 'sampler.rateLimit', value: 100, origin: 'default' },
435451
{ name: 'traceEnabled', value: true, origin: 'default' },
@@ -539,7 +555,7 @@ describe('Config', () => {
539555
process.env.DD_TRACE_PROPAGATION_STYLE_INJECT = 'b3,tracecontext'
540556
process.env.DD_TRACE_PROPAGATION_STYLE_EXTRACT = 'b3,tracecontext'
541557
process.env.DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACT = 'restart'
542-
process.env.DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED = 'true'
558+
process.env.DD_RUNTIME_METRICS_RUNTIME_ID_ENABLED = 'true'
543559
process.env.DD_TRACE_EXPERIMENTAL_EXPORTER = 'log'
544560
process.env.DD_TRACE_EXPERIMENTAL_GET_RUM_DATA_ENABLED = 'true'
545561
process.env.DD_TRACE_EXPERIMENTAL_INTERNAL_ERRORS_ENABLED = 'true'
@@ -622,6 +638,7 @@ describe('Config', () => {
622638
expect(config.grpc.server.error.statuses).to.deep.equal([3, 13, 400, 401, 402, 403])
623639
expect(config).to.have.property('middlewareTracingEnabled', false)
624640
expect(config).to.have.property('runtimeMetrics', true)
641+
expect(config).to.have.property('runtimeMetricsRuntimeId', true)
625642
expect(config).to.have.property('reportHostname', true)
626643
expect(config).to.have.nested.property('codeOriginForSpans.enabled', false)
627644
expect(config).to.have.nested.property('codeOriginForSpans.experimental.exit_spans.enabled', true)
@@ -667,7 +684,6 @@ describe('Config', () => {
667684
expect(config).to.have.nested.deep.property('tracePropagationStyle.inject', ['b3', 'tracecontext'])
668685
expect(config).to.have.nested.deep.property('tracePropagationStyle.extract', ['b3', 'tracecontext'])
669686
expect(config).to.have.nested.property('tracePropagationBehaviorExtract', 'restart')
670-
expect(config).to.have.nested.property('experimental.runtimeId', true)
671687
expect(config).to.have.nested.property('experimental.exporter', 'log')
672688
expect(config).to.have.nested.property('experimental.enableGetRumData', true)
673689
expect(config).to.have.nested.property('apmTracingEnabled', false)
@@ -751,7 +767,7 @@ describe('Config', () => {
751767
{ name: 'env', value: 'test', origin: 'env_var' },
752768
{ name: 'experimental.enableGetRumData', value: true, origin: 'env_var' },
753769
{ name: 'experimental.exporter', value: 'log', origin: 'env_var' },
754-
{ name: 'experimental.runtimeId', value: true, origin: 'env_var' },
770+
{ name: 'runtimeMetricsRuntimeId', value: true, origin: 'env_var' },
755771
{ name: 'hostname', value: 'agent', origin: 'env_var' },
756772
{ name: 'iast.dbRowsToTaint', value: 2, origin: 'env_var' },
757773
{ name: 'iast.deduplicationEnabled', value: false, origin: 'env_var' },
@@ -992,6 +1008,7 @@ describe('Config', () => {
9921008
flushMinSpans: 500,
9931009
middlewareTracingEnabled: false,
9941010
runtimeMetrics: true,
1011+
runtimeMetricsRuntimeId: true,
9951012
reportHostname: true,
9961013
plugins: false,
9971014
logLevel,
@@ -1008,7 +1025,6 @@ describe('Config', () => {
10081025
experimental: {
10091026
b3: true,
10101027
traceparent: true,
1011-
runtimeId: true,
10121028
exporter: 'log',
10131029
enableGetRumData: true,
10141030
iast: {
@@ -1066,6 +1082,7 @@ describe('Config', () => {
10661082
expect(config).to.have.property('flushMinSpans', 500)
10671083
expect(config).to.have.property('middlewareTracingEnabled', false)
10681084
expect(config).to.have.property('runtimeMetrics', true)
1085+
expect(config).to.have.property('runtimeMetricsRuntimeId', true)
10691086
expect(config).to.have.property('reportHostname', true)
10701087
expect(config).to.have.property('plugins', false)
10711088
expect(config).to.have.property('logLevel', logLevel)
@@ -1082,7 +1099,6 @@ describe('Config', () => {
10821099
expect(config.tags['runtime-id']).to.match(/^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$/)
10831100
expect(config).to.have.nested.deep.property('tracePropagationStyle.inject', ['datadog'])
10841101
expect(config).to.have.nested.deep.property('tracePropagationStyle.extract', ['datadog'])
1085-
expect(config).to.have.nested.property('experimental.runtimeId', true)
10861102
expect(config).to.have.nested.property('experimental.exporter', 'log')
10871103
expect(config).to.have.nested.property('experimental.enableGetRumData', true)
10881104
expect(config).to.have.nested.property('appsec.enabled', false)
@@ -1140,7 +1156,7 @@ describe('Config', () => {
11401156
{ name: 'env', value: 'test', origin: 'code' },
11411157
{ name: 'experimental.enableGetRumData', value: true, origin: 'code' },
11421158
{ name: 'experimental.exporter', value: 'log', origin: 'code' },
1143-
{ name: 'experimental.runtimeId', value: true, origin: 'code' },
1159+
{ name: 'runtimeMetricsRuntimeId', value: true, origin: 'code' },
11441160
{ name: 'flushInterval', value: 5000, origin: 'code' },
11451161
{ name: 'flushMinSpans', value: 500, origin: 'code' },
11461162
{ name: 'hostname', value: 'agent', origin: 'code' },
@@ -1360,7 +1376,7 @@ describe('Config', () => {
13601376
process.env.DD_TRACE_PROPAGATION_STYLE_INJECT = 'datadog'
13611377
process.env.DD_TRACE_PROPAGATION_STYLE_EXTRACT = 'datadog'
13621378
process.env.DD_TRACE_PROPAGATION_BEHAVIOR_EXTRACT = 'restart'
1363-
process.env.DD_TRACE_EXPERIMENTAL_RUNTIME_ID_ENABLED = 'true'
1379+
process.env.DD_RUNTIME_METRICS_RUNTIME_ID_ENABLED = 'true'
13641380
process.env.DD_TRACE_EXPERIMENTAL_EXPORTER = 'log'
13651381
process.env.DD_TRACE_EXPERIMENTAL_GET_RUM_DATA_ENABLED = 'true'
13661382
process.env.DD_TRACE_MIDDLEWARE_TRACING_ENABLED = 'false'
@@ -1407,6 +1423,7 @@ describe('Config', () => {
14071423
port: 8888
14081424
},
14091425
runtimeMetrics: false,
1426+
runtimeMetricsRuntimeId: false,
14101427
reportHostname: false,
14111428
flushMinSpans: 500,
14121429
service: 'test',
@@ -1440,7 +1457,6 @@ describe('Config', () => {
14401457
experimental: {
14411458
b3: false,
14421459
traceparent: false,
1443-
runtimeId: false,
14441460
exporter: 'agent',
14451461
enableGetRumData: false
14461462
},
@@ -1514,6 +1530,7 @@ describe('Config', () => {
15141530
expect(config).to.have.property('site', 'datadoghq.com')
15151531
expect(config).to.have.property('middlewareTracingEnabled', true)
15161532
expect(config).to.have.property('runtimeMetrics', false)
1533+
expect(config).to.have.property('runtimeMetricsRuntimeId', false)
15171534
expect(config).to.have.property('reportHostname', false)
15181535
expect(config).to.have.property('flushMinSpans', 500)
15191536
expect(config).to.have.property('service', 'test')
@@ -1538,7 +1555,6 @@ describe('Config', () => {
15381555
expect(config).to.have.deep.property('peerServiceMapping', { d: 'dd' })
15391556
expect(config).to.have.nested.deep.property('tracePropagationStyle.inject', [])
15401557
expect(config).to.have.nested.deep.property('tracePropagationStyle.extract', [])
1541-
expect(config).to.have.nested.property('experimental.runtimeId', false)
15421558
expect(config).to.have.nested.property('experimental.exporter', 'agent')
15431559
expect(config).to.have.nested.property('experimental.enableGetRumData', false)
15441560
expect(config).to.have.nested.property('apmTracingEnabled', true)

0 commit comments

Comments
 (0)