Skip to content

Commit c1d53e2

Browse files
authored
Turn async ID gathering off by default (#5621)
* Revert "Constrain async ID collection to main thread only (#5559)" This reverts commit 5fd6690. * Revert "Start collecting async IDs in profiles (#5524)" This reverts commit 9ec7ef9. * Restore actually useful test code change
1 parent 6b0de6c commit c1d53e2

File tree

4 files changed

+18
-57
lines changed

4 files changed

+18
-57
lines changed

integration-tests/profiler/profiler.spec.js

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -351,10 +351,9 @@ describe('profiler', () => {
351351
// 'local root span id's
352352
// - samples with spans also must have a 'trace endpoint' label with values 'endpoint-0',
353353
// 'endpoint-1', or 'endpoint-2'
354-
// - every occurrence of a span must have the same root span, endpoint, and asyncId
354+
// - every occurrence of a span must have the same root span and endpoint
355355
const rootSpans = new Set()
356356
const endpoints = new Set()
357-
const asyncIds = new Set()
358357
const spans = new Map()
359358
const strings = profile.stringTable
360359
const tsKey = strings.dedup('end_timestamp_ns')
@@ -364,13 +363,11 @@ describe('profiler', () => {
364363
const threadNameKey = strings.dedup('thread name')
365364
const threadIdKey = strings.dedup('thread id')
366365
const osThreadIdKey = strings.dedup('os thread id')
367-
const asyncIdKey = strings.dedup('async id')
368366
const threadNameValue = strings.dedup('Main Event Loop')
369367
const nonJSThreadNameValue = strings.dedup('Non-JS threads')
370368

371-
const asyncIdWorks = require('semifies')(process.versions.node, '>=22.10.0')
372369
for (const sample of profile.sample) {
373-
let ts, spanId, rootSpanId, endpoint, threadName, threadId, osThreadId, asyncId
370+
let ts, spanId, rootSpanId, endpoint, threadName, threadId, osThreadId
374371
for (const label of sample.label) {
375372
switch (label.key) {
376373
case tsKey: ts = label.num; break
@@ -380,12 +377,6 @@ describe('profiler', () => {
380377
case threadNameKey: threadName = label.str; break
381378
case threadIdKey: threadId = label.str; break
382379
case osThreadIdKey: osThreadId = label.str; break
383-
case asyncIdKey:
384-
asyncId = label.num
385-
if (asyncId === 0) {
386-
asyncId = undefined
387-
}
388-
break
389380
default: assert.fail(`Unexpected label key ${strings.dedup(label.key)} ${encoded}`)
390381
}
391382
}
@@ -419,27 +410,11 @@ describe('profiler', () => {
419410
// 3 of them.
420411
continue
421412
}
422-
const spanData = { rootSpanId, endpoint, asyncId }
423-
// Record async ID so we can verify we encountered 9 different values.
424-
// Async ID can be sporadically missing if sampling hits an intrinsified
425-
// function.
426-
if (asyncId !== undefined) {
427-
asyncIds.add(asyncId)
428-
}
413+
const spanData = { rootSpanId, endpoint }
429414
const existingSpanData = spans.get(spanId)
430415
if (existingSpanData) {
431-
// Span's root span, endpoint, and async ID must be consistent
432-
// across samples.
433-
assert.equal(existingSpanData.rootSpanId, rootSpanId, encoded)
434-
assert.equal(existingSpanData.endpoint, endpoint, encoded)
435-
if (asyncIdWorks) {
436-
// Account for asyncID sporadically missing
437-
if (existingSpanData.asyncId === undefined) {
438-
existingSpanData.asyncId = asyncId
439-
} else if (asyncId !== undefined) {
440-
assert.equal(existingSpanData.asyncId, asyncId, encoded)
441-
}
442-
}
416+
// Span's root span and endpoint must be consistent across samples
417+
assert.deepEqual(spanData, existingSpanData, encoded)
443418
} else {
444419
// New span id, store span data
445420
spans.set(spanId, spanData)
@@ -457,10 +432,9 @@ describe('profiler', () => {
457432
}
458433
}
459434
}
460-
// Need to have a total of 9 different spans, with 9 different async IDs,
461-
// 3 different root spans, and 3 different endpoints.
435+
// Need to have a total of 9 different spans, with 3 different root spans
436+
// and 3 different endpoints.
462437
assert.equal(spans.size, 9, encoded)
463-
assert.equal(asyncIds.size, asyncIdWorks ? 9 : 0, encoded)
464438
assert.equal(rootSpans.size, 3, encoded)
465439
assert.equal(endpoints.size, 3, encoded)
466440
})

packages/dd-trace/src/profiling/config.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,13 @@ const { GIT_REPOSITORY_URL, GIT_COMMIT_SHA } = require('../plugins/util/tags')
1515
const { tagger } = require('./tagger')
1616
const { isFalse, isTrue } = require('../util')
1717
const { getAzureTagsFromMetadata, getAzureAppMetadata } = require('../azure_metadata')
18-
const satisfies = require('semifies')
1918

2019
class Config {
2120
constructor (options = {}) {
2221
const {
2322
DD_AGENT_HOST,
2423
DD_ENV,
2524
DD_INTERNAL_PROFILING_TIMELINE_SAMPLING_ENABLED, // used for testing
26-
DD_PROFILING_ASYNC_ID_ENABLED,
2725
DD_PROFILING_CODEHOTSPOTS_ENABLED,
2826
DD_PROFILING_CPU_ENABLED,
2927
DD_PROFILING_DEBUG_SOURCE_MAPS,
@@ -181,10 +179,6 @@ class Config {
181179
this.timelineSamplingEnabled = isTrue(coalesce(options.timelineSamplingEnabled,
182180
DD_INTERNAL_PROFILING_TIMELINE_SAMPLING_ENABLED, true))
183181

184-
// Async ID gathering only works reliably on Node >= 22.10.0
185-
this.asyncIdEnabled = isTrue(coalesce(options.asyncIdEnabled,
186-
DD_PROFILING_ASYNC_ID_ENABLED, this.timelineEnabled && satisfies(process.versions.node, '>=22.10.0')))
187-
188182
this.codeHotspotsEnabled = isTrue(coalesce(options.codeHotspotsEnabled,
189183
DD_PROFILING_CODEHOTSPOTS_ENABLED,
190184
DD_PROFILING_EXPERIMENTAL_CODEHOTSPOTS_ENABLED, samplingContextsAvailable))

packages/dd-trace/src/profiling/profilers/wall.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,12 @@ function ensureChannelsActivated () {
7070
class NativeWallProfiler {
7171
constructor (options = {}) {
7272
this.type = 'wall'
73-
// Currently there's a crash sometimes on worker threads trying to collect async IDs so for the
74-
// time being we'll constrain it to only the main thread.
75-
this._asyncIdEnabled = !!options.asyncIdEnabled && require('worker_threads').isMainThread
73+
this._samplingIntervalMicros = options.samplingInterval || 1e6 / 99 // 99hz
74+
this._flushIntervalMillis = options.flushInterval || 60 * 1e3 // 60 seconds
7675
this._codeHotspotsEnabled = !!options.codeHotspotsEnabled
77-
this._cpuProfilingEnabled = !!options.cpuProfilingEnabled
7876
this._endpointCollectionEnabled = !!options.endpointCollectionEnabled
79-
this._flushIntervalMillis = options.flushInterval || 60 * 1e3 // 60 seconds
80-
this._samplingIntervalMicros = options.samplingInterval || 1e6 / 99 // 99hz
8177
this._timelineEnabled = !!options.timelineEnabled
82-
this._v8ProfilerBugWorkaroundEnabled = !!options.v8ProfilerBugWorkaroundEnabled
78+
this._cpuProfilingEnabled = !!options.cpuProfilingEnabled
8379
// We need to capture span data into the sample context for either code hotspots
8480
// or endpoint collection.
8581
this._captureSpanData = this._codeHotspotsEnabled || this._endpointCollectionEnabled
@@ -88,6 +84,7 @@ class NativeWallProfiler {
8884
// timestamps require the sample contexts feature in the pprof wall profiler), or
8985
// cpu profiling is enabled.
9086
this._withContexts = this._captureSpanData || this._timelineEnabled || this._cpuProfilingEnabled
87+
this._v8ProfilerBugWorkaroundEnabled = !!options.v8ProfilerBugWorkaroundEnabled
9188
this._mapper = undefined
9289
this._pprof = undefined
9390

@@ -128,14 +125,13 @@ class NativeWallProfiler {
128125
}
129126

130127
this._pprof.time.start({
131-
collectAsyncId: this._asyncIdEnabled,
132-
collectCpuTime: this._cpuProfilingEnabled,
133-
durationMillis: this._flushIntervalMillis,
134128
intervalMicros: this._samplingIntervalMicros,
135-
lineNumbers: false,
129+
durationMillis: this._flushIntervalMillis,
136130
sourceMapper: this._mapper,
137131
withContexts: this._withContexts,
138-
workaroundV8Bug: this._v8ProfilerBugWorkaroundEnabled
132+
lineNumbers: false,
133+
workaroundV8Bug: this._v8ProfilerBugWorkaroundEnabled,
134+
collectCpuTime: this._cpuProfilingEnabled
139135
})
140136

141137
if (this._withContexts) {

packages/dd-trace/test/profiling/profilers/wall.spec.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ describe('profilers/native/wall', () => {
5858
withContexts: false,
5959
lineNumbers: false,
6060
workaroundV8Bug: false,
61-
collectCpuTime: false,
62-
collectAsyncId: false
61+
collectCpuTime: false
6362
})
6463
})
6564

@@ -78,8 +77,7 @@ describe('profilers/native/wall', () => {
7877
withContexts: false,
7978
lineNumbers: false,
8079
workaroundV8Bug: false,
81-
collectCpuTime: false,
82-
collectAsyncId: false
80+
collectCpuTime: false
8381
})
8482
})
8583

@@ -175,8 +173,7 @@ describe('profilers/native/wall', () => {
175173
withContexts: false,
176174
lineNumbers: false,
177175
workaroundV8Bug: false,
178-
collectCpuTime: false,
179-
collectAsyncId: false
176+
collectCpuTime: false
180177
})
181178
})
182179

0 commit comments

Comments
 (0)