diff --git a/docs/test.ts b/docs/test.ts index 879a7e4da18..a511b0ac4e3 100644 --- a/docs/test.ts +++ b/docs/test.ts @@ -40,7 +40,7 @@ let promise: Promise; ddTrace.init(); tracer.init({ apmTracingEnabled: false, - logInjection: true, + logInjection: 'structured', startupLogs: false, env: 'test', version: '1.0.0', diff --git a/index.d.ts b/index.d.ts index 8a304e017be..a610a1c6b4d 100644 --- a/index.d.ts +++ b/index.d.ts @@ -373,9 +373,13 @@ declare namespace tracer { /** * Whether to enable trace ID injection in log records to be able to correlate * traces with logs. - * @default false + * all: enable for both structured and unstructured logs + * structured: enable only for structured logs + * (same as 'all' since dd-trace does support log injection for unstructured logs) + * disabled: disable trace ID injection in all logs + * @default 'structured' */ - logInjection?: boolean, + logInjection?: string, /** * Whether to enable startup logs. diff --git a/packages/dd-trace/src/plugins/log_plugin.js b/packages/dd-trace/src/plugins/log_plugin.js index 13be586573f..0b8c03e33b6 100644 --- a/packages/dd-trace/src/plugins/log_plugin.js +++ b/packages/dd-trace/src/plugins/log_plugin.js @@ -2,6 +2,7 @@ const { LOG } = require('../../../../ext/formats') const Plugin = require('./plugin') +const log = require('../log') const { storage } = require('../../../datadog-core') function messageProxy (message, holder) { @@ -46,10 +47,17 @@ module.exports = class LogPlugin extends Plugin { } _isEnabled (config) { - return config.enabled && (config.logInjection === true || config.ciVisAgentlessLogSubmissionEnabled) + return config.enabled && + (config.logInjection === 'all' || config.logInjection === true || config.ciVisAgentlessLogSubmissionEnabled) } configure (config) { + if (config.logInjection === true) { + log.warn('Boolean value for config.logInjection is deprecated. Use "all" or "structured" instead.') + } + if (config.logInjection === false) { + log.warn('Boolean value for config.logInjection is deprecated. Use "disabled" instead.') + } return super.configure({ ...config, enabled: this._isEnabled(config)