Nestjs-OpenTelemetry
Nestjs-OpenTelemetry copied to clipboard
Question: How does this module work?
My understanding is that the NodeJS OTEL implementation has to monkey patch the instrumented modules BEFORE any other modules require them.
This module only initialises the SDK after bootstrapping the app, which means that all modules must have been imported into the app module already.
Am I misunderstanding something here?
Asking more out of curiosity than anything.
It probably won't work with every instrumentation, say mongoose
or amqplib
or pino
, but seem to work fine with http
instrumentation. I'm not sure why http
does work but here's some speculations:
This is what I had using even non-module way of starting SDK:
This works and said libraries get instrumented:
import openTelemetrySDK from './shared/open-telemetry/tracing-telemetry-sdk.setup'
import { Logger } from 'nestjs-pino'
...other imports
const logger = new Logger('AppBootstrap')
async function bootstrap(): Promise<void> {
try {
await openTelemetrySDK.start()
This setup won't be able to patch mongoose
, pino
etc. and traces won't be shown in jaeger/injected in pino logs. But some instrumentations will still work somehow
...other imports (I think `AppModule` import being one of the most important in this case)
import { Logger } from 'nestjs-pino'
import openTelemetrySDK from './shared/open-telemetry/tracing-telemetry-sdk.setup'
const logger = new Logger('AppBootstrap')
async function bootstrap(): Promise<void> {
try {
await openTelemetrySDK.start()
So I think the main goal for this library is tracing what's inside the app without going too deep in other things such as injections in logs, DBs, queues etc. If that's the case - the current implementation is good to go
In the end I'd say that you might face some issues when trying to go for a more detailed setup since as you said
NodeJS OTEL implementation has to monkey patch the instrumented modules BEFORE any other modules require them
Why did you close this? @MetinSeylan