I'm using @opentelemtry/api library, and my goal is to write an interceptor that is going to start an active span for every route in the controller. I'm not familiar with RxJs and interceptors uses it. How can I wrap next.handle() call so I can start/stop the span correctly?
This is what I've tried, but this solution does not propagate the context correctly - every span created during controller exeuction is not nested into this active span that I'm creating in the interceptor...
intercept(context: ExecutionContext, next: CallHandler): Observable<any> {
const tracer = trace.getTracer('default')
tracer.startActiveSpan('test', (span) => {
return next
.handle()
.pipe(
tap(() => span.end()),
);
})
}```