Skip to content

Commit

Permalink
Enable log collection by default
Browse files Browse the repository at this point in the history
  • Loading branch information
iunanua committed Nov 22, 2024
1 parent f130f4c commit b576603
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 21 deletions.
8 changes: 1 addition & 7 deletions packages/dd-trace/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ class Config {
this._setValue(defaults, 'telemetry.dependencyCollection', true)
this._setValue(defaults, 'telemetry.enabled', true)
this._setValue(defaults, 'telemetry.heartbeatInterval', 60000)
this._setValue(defaults, 'telemetry.logCollection', false)
this._setValue(defaults, 'telemetry.logCollection', true)
this._setValue(defaults, 'telemetry.metrics', true)
this._setValue(defaults, 'traceEnabled', true)
this._setValue(defaults, 'traceId128BitGenerationEnabled', true)
Expand Down Expand Up @@ -1142,12 +1142,6 @@ class Config {
calc['tracePropagationStyle.extract'] = calc['tracePropagationStyle.extract'] || defaultPropagationStyle
}

const iastEnabled = coalesce(this._options['iast.enabled'], this._env['iast.enabled'])
const profilingEnabled = coalesce(this._options['profiling.enabled'], this._env['profiling.enabled'])
const injectionIncludesProfiler = (this._env.injectionEnabled || []).includes('profiler')
if (iastEnabled || ['auto', 'true'].includes(profilingEnabled) || injectionIncludesProfiler) {
this._setBoolean(calc, 'telemetry.logCollection', true)
}
if (this._env.injectionEnabled?.length > 0) {
this._setBoolean(calc, 'crashtracking.enabled', true)
}
Expand Down
1 change: 1 addition & 0 deletions packages/dd-trace/src/telemetry/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ function appClosing () {
sendData(config, application, host, reqType, payload)
// We flush before shutting down.
metricsManager.send(config, application, host)
telemetryLogger.send(config, application, host)
}

function onBeforeExit () {
Expand Down
17 changes: 3 additions & 14 deletions packages/dd-trace/test/config.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ describe('Config', () => {
{ name: 'telemetry.dependencyCollection', value: true, origin: 'default' },
{ name: 'telemetry.enabled', value: true, origin: 'env_var' },
{ name: 'telemetry.heartbeatInterval', value: 60000, origin: 'default' },
{ name: 'telemetry.logCollection', value: false, origin: 'default' },
{ name: 'telemetry.logCollection', value: true, origin: 'default' },
{ name: 'telemetry.metrics', value: true, origin: 'default' },
{ name: 'traceId128BitGenerationEnabled', value: true, origin: 'default' },
{ name: 'traceId128BitLoggingEnabled', value: false, origin: 'default' },
Expand Down Expand Up @@ -1577,7 +1577,7 @@ describe('Config', () => {
expect(config.telemetry).to.not.be.undefined
expect(config.telemetry.enabled).to.be.true
expect(config.telemetry.heartbeatInterval).to.eq(60000)
expect(config.telemetry.logCollection).to.be.false
expect(config.telemetry.logCollection).to.be.true
expect(config.telemetry.debug).to.be.false
expect(config.telemetry.metrics).to.be.true
})
Expand Down Expand Up @@ -1615,7 +1615,7 @@ describe('Config', () => {
process.env.DD_TELEMETRY_METRICS_ENABLED = origTelemetryMetricsEnabledValue
})

it('should not set DD_TELEMETRY_LOG_COLLECTION_ENABLED', () => {
it('should disable log collection if DD_TELEMETRY_LOG_COLLECTION_ENABLED is false', () => {
const origLogsValue = process.env.DD_TELEMETRY_LOG_COLLECTION_ENABLED
process.env.DD_TELEMETRY_LOG_COLLECTION_ENABLED = 'false'

Expand All @@ -1626,17 +1626,6 @@ describe('Config', () => {
process.env.DD_TELEMETRY_LOG_COLLECTION_ENABLED = origLogsValue
})

it('should set DD_TELEMETRY_LOG_COLLECTION_ENABLED if DD_IAST_ENABLED', () => {
const origIastEnabledValue = process.env.DD_IAST_ENABLED
process.env.DD_IAST_ENABLED = 'true'

const config = new Config()

expect(config.telemetry.logCollection).to.be.true

process.env.DD_IAST_ENABLED = origIastEnabledValue
})

it('should set DD_TELEMETRY_DEBUG', () => {
const origTelemetryDebugValue = process.env.DD_TELEMETRY_DEBUG
process.env.DD_TELEMETRY_DEBUG = 'true'
Expand Down

0 comments on commit b576603

Please sign in to comment.