Skip to content

Commit

Permalink
only start crashtracking when enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
rochdev committed Sep 19, 2024
1 parent 380ceba commit f2df62c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
4 changes: 3 additions & 1 deletion packages/dd-trace/src/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ class Tracer extends NoopProxy {
try {
const config = new Config(options) // TODO: support dynamic code config

require('./crashtracking').start(config) // TODO: start earlier in process
if (config.crashtracking.enabled) {
require('./crashtracking').start(config)
}

telemetry.start(config, this._pluginManager)

Expand Down
21 changes: 3 additions & 18 deletions packages/dd-trace/test/proxy.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ describe('TracerProxy', () => {
let dogStatsD
let noopDogStatsDClient
let NoopDogStatsDClient
let crashtracker
let noopCrashtracker

beforeEach(() => {
process.env.DD_TRACE_MOCHA_ENABLED = false
Expand Down Expand Up @@ -130,6 +128,7 @@ describe('TracerProxy', () => {
profiling: {},
appsec: {},
iast: {},
crashtracking: {},
remoteConfig: {
enabled: true
},
Expand Down Expand Up @@ -179,19 +178,10 @@ describe('TracerProxy', () => {

remoteConfig.enable.returns(rc)

crashtracker = {
start: sinon.spy()
}

noopCrashtracker = {
start: sinon.spy()
}

NoopProxy = proxyquire('../src/noop/proxy', {
'./tracer': NoopTracer,
'../appsec/sdk/noop': NoopAppsecSdk,
'./dogstatsd': NoopDogStatsDClient,
'./crashtracking': noopCrashtracker
'./dogstatsd': NoopDogStatsDClient
})

Proxy = proxyquire('../src/proxy', {
Expand All @@ -209,8 +199,7 @@ describe('TracerProxy', () => {
'./appsec/sdk': AppsecSdk,
'./dogstatsd': dogStatsD,
'./noop/dogstatsd': NoopDogStatsDClient,
'./flare': flare,
'./crashtracking': crashtracker
'./flare': flare
})

proxy = new Proxy()
Expand Down Expand Up @@ -329,7 +318,6 @@ describe('TracerProxy', () => {
it('should support applying remote config', () => {
const RemoteConfigProxy = proxyquire('../src/proxy', {
'./tracer': DatadogTracer,
'./crashtracking': crashtracker,
'./appsec': appsec,
'./appsec/iast': iast,
'./appsec/remote_config': remoteConfig,
Expand Down Expand Up @@ -359,7 +347,6 @@ describe('TracerProxy', () => {
it('should support applying remote config (only call disable if enabled before)', () => {
const RemoteConfigProxy = proxyquire('../src/proxy', {
'./tracer': DatadogTracer,
'./crashtracking': crashtracker,
'./config': Config,
'./appsec': appsec,
'./appsec/iast': iast,
Expand Down Expand Up @@ -519,7 +506,6 @@ describe('TracerProxy', () => {

const ProfilerImportFailureProxy = proxyquire('../src/proxy', {
'./tracer': DatadogTracer,
'./crashtracking': crashtracker,
'./noop/tracer': NoopTracer,
'./config': Config,
'./runtime_metrics': runtimeMetrics,
Expand Down Expand Up @@ -551,7 +537,6 @@ describe('TracerProxy', () => {
const options = {}
const DatadogProxy = proxyquire('../src/proxy', {
'./tracer': DatadogTracer,
'./crashtracking': crashtracker,
'./config': Config,
'./appsec': appsec,
'./appsec/iast': iast,
Expand Down

0 comments on commit f2df62c

Please sign in to comment.