-
Notifications
You must be signed in to change notification settings - Fork 317
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PROF-9791: Use heuristics to start the profiler when requested through SSI #4322
Changes from all commits
5126bfc
5f018fe
6596c65
b61a677
a569529
e3b5af9
da6b782
6339755
e76c79e
4fcbf02
9ca48ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -485,9 +485,12 @@ class Config { | |
this._setValue(defaults, 'peerServiceMapping', {}) | ||
this._setValue(defaults, 'plugins', true) | ||
this._setValue(defaults, 'port', '8126') | ||
this._setValue(defaults, 'profiling.enabled', false) | ||
this._setValue(defaults, 'profiling.enabled', undefined) | ||
this._setValue(defaults, 'profiling.exporters', 'agent') | ||
this._setValue(defaults, 'profiling.sourceMap', true) | ||
this._setValue(defaults, 'profiling.ssi', false) | ||
this._setValue(defaults, 'profiling.heuristicsEnabled', false) | ||
this._setValue(defaults, 'profiling.longLivedThreshold', undefined) | ||
this._setValue(defaults, 'protocolVersion', '0.4') | ||
this._setValue(defaults, 'queryStringObfuscation', qsRegex) | ||
this._setValue(defaults, 'remoteConfig.enabled', true) | ||
|
@@ -558,6 +561,7 @@ class Config { | |
DD_PROFILING_ENABLED, | ||
DD_PROFILING_EXPORTERS, | ||
DD_PROFILING_SOURCE_MAP, | ||
DD_INTERNAL_PROFILING_LONG_LIVED_THRESHOLD, | ||
DD_REMOTE_CONFIGURATION_ENABLED, | ||
DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS, | ||
DD_RUNTIME_METRICS_ENABLED, | ||
|
@@ -663,6 +667,17 @@ class Config { | |
this._setBoolean(env, 'profiling.enabled', coalesce(DD_EXPERIMENTAL_PROFILING_ENABLED, DD_PROFILING_ENABLED)) | ||
this._setString(env, 'profiling.exporters', DD_PROFILING_EXPORTERS) | ||
this._setBoolean(env, 'profiling.sourceMap', DD_PROFILING_SOURCE_MAP && !isFalse(DD_PROFILING_SOURCE_MAP)) | ||
if (DD_INJECTION_ENABLED) { | ||
this._setBoolean(env, 'profiling.ssi', true) | ||
if (DD_INJECTION_ENABLED.split(',').includes('profiler')) { | ||
this._setBoolean(env, 'profiling.heuristicsEnabled', true) | ||
} | ||
if (DD_INTERNAL_PROFILING_LONG_LIVED_THRESHOLD) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Having two different naming for the same thing (long lived / short lived threshold) feels weird. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know – it already was there as "short lived" for telemetry, but we usually mentioned a "long-lived" process so this felt more natural. I was vacillating on renaming the internal variable but then thought I might do it in a separate step later to keep this smaller. I might add a commit to fix this though. |
||
// This is only used in testing to not have to wait 30s | ||
this._setValue(env, 'profiling.longLivedThreshold', Number(DD_INTERNAL_PROFILING_LONG_LIVED_THRESHOLD)) | ||
} | ||
} | ||
|
||
this._setString(env, 'protocolVersion', DD_TRACE_AGENT_PROTOCOL_VERSION) | ||
this._setString(env, 'queryStringObfuscation', DD_TRACE_OBFUSCATION_QUERY_STRING_REGEXP) | ||
this._setBoolean(env, 'remoteConfig.enabled', coalesce( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it ok to put logic here? this seems to stray from the simple
this._setBoolean/Value
sequence of statement.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think yes. There's some other
if
statements in the method already.