#NestInstrumentation not working
11 messages · Page 1 of 1 (latest)
Could you share a snippet of your code for the array instrumentations ?
If you are using https://www.npmjs.com/package/@opentelemetry/auto-instrumentations-node in that array, it automatically adds the nestjs-core one, so you are probably injecting it twice
Metapackage which bundles opentelemetry node core and contrib instrumentations. Latest version: 0.39.4, last published: 14 days ago. Start using @opentelemetry/auto-instrumentations-node in your project by running npm i @opentelemetry/auto-instrumentations-node. There are 191 other projects in the npm registry using @opentelemetry/auto-instrum...
ref: https://www.npmjs.com/package/@opentelemetry/auto-instrumentations-node#supported-instrumentations
Metapackage which bundles opentelemetry node core and contrib instrumentations. Latest version: 0.39.4, last published: 14 days ago. Start using @opentelemetry/auto-instrumentations-node in your project by running npm i @opentelemetry/auto-instrumentations-node. There are 191 other projects in the npm registry using @opentelemetry/auto-instrum...
Hey hey, just bumping into this post.
I have a NestJS service, with instrumentation.ts looking like this:
const traceExporter = new OTLPTraceExporter({
url: 'http://localhost:4318/v1/traces',
});
const spanProcessor = new BatchSpanProcessor(traceExporter);
const otelSDK = new NodeSDK({
metricReader: new PrometheusExporter({
port: 9100,
}),
spanProcessor,
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: 'authentication',
}),
contextManager: new AsyncLocalStorageContextManager(),
instrumentations: [getNodeAutoInstrumentations()],
textMapPropagator: new CompositePropagator({
propagators: [
new W3CTraceContextPropagator(),
new W3CBaggagePropagator(),
new B3Propagator(),
new B3Propagator({
injectEncoding: B3InjectEncoding.MULTI_HEADER,
}),
],
}),
});
export default otelSDK;
But I don't see any trace of NestJS instrumentation. Shouldn't it be part of getNodeAutoInstrumentations()?
The spans looks very Express specific
Even with trying with your project
https://github.com/pragmaticivan/nestjs-otel-prom-grafana-tempo/tree/main
I don't see any NestJS specific instrumentation @umbral flower
I found the issue, I need to import the otelSdk before any nest imports in main file 🙂
Hey, sorry, I've been off for a while 😂 I was waiting for an update from the OTEL JS core, yes
It doesn't help that I've been mostly coding in Go lol
All good 🙂 I manage to solve it.
One weird thing tho, maybe you have an idea:
For my NestJS logger I use requestId from Nest/Express as a traceId. But Otel is generating a different ID 😅 Why using the request Id as well?
@umbral flower Did you notice some issues with trace propagation in NestJS?
I can see on your example and one I created myself that the response headers are missing traceparent/traceId headers
I tested with NodeSDK, getNodeAutoInstrumentations and with/without the full blown of textMapPropagator (B3Propagator, W3CBaggagePropagator, W3CTraceContextPropagator)
Edit: Fetch is not instrumented