Skip to content

Commit

Permalink
Extract profiler start code, soon we'll be using it twice
Browse files Browse the repository at this point in the history
  • Loading branch information
szegedi committed May 17, 2024
1 parent 318f118 commit 3bb306f
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions packages/dd-trace/src/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,7 @@ class Tracer extends NoopProxy {
const ssiTelemetry = new SSITelemetry(config.profiling)
ssiTelemetry.start()
if (config.profiling.enabled) {
// do not stop tracer initialization if the profiler fails to be imported
try {
const profiler = require('./profiler')
this._profilerStarted = profiler.start(config)
} catch (e) {
log.error(e)
telemetryLog.publish({
message: e.message,
level: 'ERROR',
stack_trace: e.stack
})
}
this._profilerStarted = this._startProfiler(config)
} else if (ssiTelemetry.enabled()) {
require('./profiling/ssi-telemetry-mock-profiler').start(config)
}
Expand Down Expand Up @@ -138,6 +127,22 @@ class Tracer extends NoopProxy {
return this
}

_startProfiler (config) {
// do not stop tracer initialization if the profiler fails to be imported
try {
return require('./profiler').start(config)
} catch (e) {
log.error(e)
if (telemetryLog.hasSubscribers) {
telemetryLog.publish({
message: e.message,
level: 'ERROR',
stack_trace: e.stack
})
}
}
}

_enableOrDisableTracing (config) {
if (config.tracing !== false) {
if (config.appsec.enabled) {
Expand Down

0 comments on commit 3bb306f

Please sign in to comment.