Skip to content

Commit

Permalink
set logger
Browse files Browse the repository at this point in the history
  • Loading branch information
sjvans committed Dec 6, 2023
1 parent 105401f commit 5a28fee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const { diag, DiagConsoleLogger } = require('@opentelemetry/api')
const { diag } = require('@opentelemetry/api')

const tracing = require('./tracing')
const metrics = require('./metrics')
const { getDiagLogLevel, getResource } = require('./utils')

module.exports = function () {
// propagate log level to opentelemetry
if (!process.env.OTEL_LOG_LEVEL) diag.setLogger(new DiagConsoleLogger(), getDiagLogLevel())
// set logger and propagate log level
diag.setLogger(cds.log('telemetry'), process.env.OTEL_LOG_LEVEL || getDiagLogLevel())

const resource = getResource()

Expand Down
6 changes: 3 additions & 3 deletions lib/metrics/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ module.exports = resource => {
'/var/lib/dynatrace/enrichment/dt_metadata.json'
]) {
try {
LOG.info(`Reading dtmetadata "${name}" ...`)
LOG._debug && LOG.debug(`Trying to read dtmetadata source "${name}" ...`)
const content = fs.readFileSync(name.startsWith('/var') ? name : fs.readFileSync(name).toString('utf-8').trim()).toString('utf-8')
LOG.info('Content:', content)
LOG._debug && LOG.debug('Successful')
dtmetadata = dtmetadata.merge(new Resource(JSON.parse(content)))
break
} catch (err) {
LOG.info('Failed with error:', err)
LOG._debug && LOG.debug('Failed with error:', err)
}
}

Expand Down

0 comments on commit 5a28fee

Please sign in to comment.