Skip to content

Commit

Permalink
Added a test
Browse files Browse the repository at this point in the history
  • Loading branch information
szegedi committed Mar 10, 2025
1 parent c3333c5 commit 3976cb7
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions packages/dd-trace/test/startup-log.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ require('./setup/tap')

const os = require('os')
const tracerVersion = require('../../../package.json').version
const Config = require('../src/config')

describe('startup logging', () => {
let firstStderrCall
Expand Down Expand Up @@ -91,3 +92,32 @@ describe('startup logging', () => {
expect(integrationsLoaded).to.include('semver')
})
})

describe('profiling_enabled', () => {
it('should be correctly logged', () => {
[
[undefined, false],
['false', false],
['FileNotFound', false],
['auto', true],
['true', true]
].forEach(([envVar, expected]) => {
sinon.stub(console, 'info')
delete require.cache[require.resolve('../src/startup-log')]
const {
setStartupLogConfig,
setStartupLogPluginManager,
startupLog
} = require('../src/startup-log')
process.env.DD_PROFILING_ENABLED = envVar
process.env.DD_TRACE_STARTUP_LOGS = 'true'
setStartupLogConfig(new Config())
setStartupLogPluginManager({ _pluginsByName: {} })
startupLog()
/* eslint-disable-next-line no-console */
const logObj = JSON.parse(console.info.firstCall.args[0].replace('DATADOG TRACER CONFIGURATION - ', ''))
console.info.restore() /* eslint-disable-line no-console */
expect(logObj.profiling_enabled).to.equal(expected)
})
})
})

0 comments on commit 3976cb7

Please sign in to comment.