sentry-javascript icon indicating copy to clipboard operation
sentry-javascript copied to clipboard

Instrumenting Next.js SSR process

Open nikolovlazar opened this issue 7 months ago • 3 comments

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.

Image

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!

nikolovlazar avatar May 29 '25 18:05 nikolovlazar

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.

Lms24 avatar May 30 '25 07:05 Lms24

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.

nikolovlazar avatar May 30 '25 11:05 nikolovlazar

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 👍

chargome avatar May 30 '25 11:05 chargome