Instrumenting Next.js SSR process
Problem Statement
Looking at the Next.js trace it produces out of the box, there's a period after "data fetching" and starting to send back the response that's not instrumented and looks blank.
I'm assuming this is when Next.js renders the React component subtree, and generates HTML + RSC Payload, but it's not really self-explanatory. Is it possible to add spans to make it clear to the users what happens during that period?
Solution Brainstorm
Spans!
Agreed, we should try to find out what's going on during this blank time. To get to the bottom of this:
- can you share a link to the Sentry event?
- can you share a reproduction for a gap like this?
- we can hook up profiling and take a look at what NextJS is doing during this gap to get a better understanding of what should be instrumented.
Can't promise that we'll actually be able to instrument this. It might also be something we could rather contribute to NextJS' span emissions rather than trying to instrument from within the SDK. Gonna cc @chargome but also gonna backlog for now.
sounds good! here's a trace link. This is the project that produces the trace: https://github.com/codyde/ErrorFix-Workshop. It's not instrumented by default, but I didn't do anything special other than running the wizard.
Thanks @nikolovlazar , we'll look into it! But as Lukas already mentioned these spans are coming directly from the framework. We do have this on our radar anyway to improve the tracing quality upstream 👍