Skip to content

Commit

Permalink
Add Support For Mapping OTEL_LOG_LEVEL='debug' (#4363)
Browse files Browse the repository at this point in the history
* An OTEL_LOG_LEVEL of debug should also be mapped to  DD_TRACE_DEBUG=true
  • Loading branch information
khanayan123 authored Jun 3, 2024
1 parent 60f10dd commit e60feae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/dd-trace/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ class Config {
// Configure the logger first so it can be used to warn about other configs
this.debug = isTrue(coalesce(
process.env.DD_TRACE_DEBUG,
process.env.OTEL_LOG_LEVEL && process.env.OTEL_LOG_LEVEL === 'debug',
false
))
this.logger = options.logger
Expand Down
7 changes: 5 additions & 2 deletions packages/dd-trace/test/config.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ describe('Config', () => {
process.env.DD_SERVICE = 'service'
process.env.OTEL_SERVICE_NAME = 'otel_service'
process.env.DD_TRACE_LOG_LEVEL = 'error'
process.env.DD_TRACE_DEBUG = 'false'
process.env.OTEL_LOG_LEVEL = 'debug'
process.env.DD_TRACE_SAMPLE_RATE = '0.5'
process.env.OTEL_TRACES_SAMPLER = 'traceidratio'
Expand All @@ -93,6 +94,7 @@ describe('Config', () => {

const config = new Config()

expect(config).to.have.property('debug', false)
expect(config).to.have.property('service', 'service')
expect(config).to.have.property('logLevel', 'error')
expect(config).to.have.property('sampleRate', 0.5)
Expand All @@ -109,7 +111,7 @@ describe('Config', () => {

it('should initialize with OTEL environment variables when DD env vars are not set', () => {
process.env.OTEL_SERVICE_NAME = 'otel_service'
process.env.OTEL_LOG_LEVEL = 'warn'
process.env.OTEL_LOG_LEVEL = 'debug'
process.env.OTEL_TRACES_SAMPLER = 'traceidratio'
process.env.OTEL_TRACES_SAMPLER_ARG = '0.1'
process.env.OTEL_TRACES_EXPORTER = 'none'
Expand All @@ -119,8 +121,9 @@ describe('Config', () => {

const config = new Config()

expect(config).to.have.property('debug', true)
expect(config).to.have.property('service', 'otel_service')
expect(config).to.have.property('logLevel', 'warn')
expect(config).to.have.property('logLevel', 'debug')
expect(config).to.have.property('sampleRate', 0.1)
expect(config).to.have.property('runtimeMetrics', false)
expect(config.tags).to.include({ foo: 'bar1', baz: 'qux1' })
Expand Down

0 comments on commit e60feae

Please sign in to comment.