-
Notifications
You must be signed in to change notification settings - Fork 317
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PROF-9791: Use heuristics to start the profiler when requested throug…
…h SSI (#4322)
- Loading branch information
1 parent
1f304b1
commit c86bd14
Showing
11 changed files
with
308 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict' | ||
|
||
const DDTrace = require('dd-trace') | ||
|
||
const tracer = DDTrace.init() | ||
|
||
async function run () { | ||
const tasks = [] | ||
// If launched with 'create-span', the app will create a span. | ||
if (process.argv.includes('create-span')) { | ||
tasks.push(tracer.trace('woo', _ => { | ||
return new Promise(setImmediate) | ||
})) | ||
} | ||
// If launched with 'long-lived', the app will remain alive long enough to | ||
// be considered long-lived by profiler activation heuristics. | ||
if (process.argv.includes('long-lived')) { | ||
const longLivedThreshold = Number(process.env.DD_INTERNAL_PROFILING_LONG_LIVED_THRESHOLD) | ||
tasks.push(new Promise(resolve => setTimeout(resolve, longLivedThreshold + 200))) | ||
} | ||
await Promise.all(tasks) | ||
} | ||
|
||
tracer.profilerStarted().then(run) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.