Skip to content

Commit

Permalink
[test visibility] Enable log collection for test visibility (#4657)
Browse files Browse the repository at this point in the history
  • Loading branch information
juan-fernandez authored Sep 10, 2024
1 parent 9961a08 commit d6f5ded
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 22 deletions.
9 changes: 1 addition & 8 deletions packages/dd-trace/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,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, 'traceId128BitGenerationEnabled', true)
this._setValue(defaults, 'traceId128BitLoggingEnabled', false)
Expand Down Expand Up @@ -1068,13 +1068,6 @@ class Config {
calc['tracePropagationStyle.inject'] = calc['tracePropagationStyle.inject'] || defaultPropagationStyle
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)
}
}

_applyRemote (options) {
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 @@ -360,7 +360,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 @@ -1450,7 +1450,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 @@ -1488,7 +1488,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 @@ -1499,17 +1499,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 d6f5ded

Please sign in to comment.