Gajus

A source of truth for my thoughts about engineering and startups

How to enable open telemetry logs?

Engineering

Frustratingly, @opentelemetry/auto-instrumentations-node does not log anything by default.

Their documentation also misleads you into thinking that you can enable logs by setting the OTEL_LOG_LEVEL environment variable to debug or trace.

https://opentelemetry.io/docs/languages/js/automatic/

I have not been successful with those approaches.

The only thing that worked was to manually configure the logger:

const { diag, DiagConsoleLogger, DiagLogLevel } = require('@opentelemetry/api');
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');
 
diag.setLogger(new DiagConsoleLogger(), DiagLogLevel.DEBUG);
 
getNodeAutoInstrumentations();
 
// ...