Skip to content

Commit

Permalink
Revert "[test visibility] Enable log collection for test visibility (#…
Browse files Browse the repository at this point in the history
…4657)" (#4708)

This reverts commit d6f5ded.
  • Loading branch information
juan-fernandez authored Sep 20, 2024
1 parent faa76cf commit 10ac75c
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
9 changes: 8 additions & 1 deletion packages/dd-trace/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,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', true)
this._setValue(defaults, 'telemetry.logCollection', false)
this._setValue(defaults, 'telemetry.metrics', true)
this._setValue(defaults, 'traceId128BitGenerationEnabled', true)
this._setValue(defaults, 'traceId128BitLoggingEnabled', false)
Expand Down Expand Up @@ -1071,6 +1071,13 @@ 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: 0 additions & 1 deletion packages/dd-trace/src/telemetry/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ 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: 14 additions & 3 deletions packages/dd-trace/test/config.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,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: true, origin: 'default' },
{ name: 'telemetry.logCollection', value: false, 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 @@ -1461,7 +1461,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.true
expect(config.telemetry.logCollection).to.be.false
expect(config.telemetry.debug).to.be.false
expect(config.telemetry.metrics).to.be.true
})
Expand Down Expand Up @@ -1499,7 +1499,7 @@ describe('Config', () => {
process.env.DD_TELEMETRY_METRICS_ENABLED = origTelemetryMetricsEnabledValue
})

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

Expand All @@ -1510,6 +1510,17 @@ 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 10ac75c

Please sign in to comment.