Issues with OpenTelemetry Spans in Next.js Environment
Hi everyone, I'm working with OTEL in a Nextjs environment but I'm not able to get layer spans to work correctly.
Given the following code, when I make a request for the first time I get two traces:
- one trace has the all the Nextjs spans, and all my
- the other trace only has the
Every subsequent request only has one trace with all the
My expectation would be that on the first request I should have all the Nextjs spans + all my spans to belong to the same trace.
For some reasons it seems that
Any idea on what's wrong with my code? Thank you
Given the following code, when I make a request for the first time I get two traces:
- one trace has the all the Nextjs spans, and all my
ON EVERY REQUEST spans nested correctly- the other trace only has the
ON FIRST REQUEST ONLY - 3 span, while the other ON FIRST REQUEST ONLY spans are nowhere to be seen.Every subsequent request only has one trace with all the
ON EVERY REQUEST and Nextjs spans, which is what I expect because layers have already been built.My expectation would be that on the first request I should have all the Nextjs spans + all my spans to belong to the same trace.
For some reasons it seems that
Layer.withSpan doesn't create any span in this case, while Effect.withSpan attached to my service constructor effect does, but on a different trace.Any idea on what's wrong with my code? Thank you
