You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using the module (which is great btw), however I've noticed that parent ids are not being allocated correctly to nested spans.
With a simple app that imports the default OpenTelemetryModule module and has a controller that calls some service methods, the spans that are generated all have a parentId of the root span instead of their actual parents:
HTTP (id: 1, parentId: undefined)
-> Controller (id: 2, parentId: 1)
-> Service1 (id: 3, parentId: 1) - parentId should be 2
-> Service3 (id: 5, parentId: 1) - parentId should be 3
-> Service2 (id: 4, parentId: 1) - parentId should be 2
This means that spans aren't being grouped correctly.
I've applied a patch to my local version which corrects this behaviour and am happy to submit a PR here as well but wanted to get an opinion on it first in case there's something fundamentally wrong with what i'm doing that i'm not aware of 😄
classBaseTraceInjector{protectedwrap(){constmethod={[prototype.name]: function(...args: any[]){consttracer=trace.getTracer('default');// this is the offender - trace.getSpan(context.active()) always returns the top level 'default' span//const currentSpan = trace.getSpan(context.active()) ?? tracer.startSpan('default');// instead create the new span with the traceName outside of context.with and use that to create the context// all nested spans will now be allocated this span as their parentconstspan=tracer.startSpan(traceName);returncontext.with(trace.setSpan(context.active(),span),()=>{// no need to create the span inside here now//const span = tracer.startSpan(traceName);// everything else stays the same}}
The text was updated successfully, but these errors were encountered:
I'm using the module (which is great btw), however I've noticed that parent ids are not being allocated correctly to nested spans.
With a simple app that imports the default
OpenTelemetryModule
module and has a controller that calls some service methods, the spans that are generated all have a parentId of the root span instead of their actual parents:This means that spans aren't being grouped correctly.
I've applied a patch to my local version which corrects this behaviour and am happy to submit a PR here as well but wanted to get an opinion on it first in case there's something fundamentally wrong with what i'm doing that i'm not aware of 😄
The text was updated successfully, but these errors were encountered: