What does NextNodeServer.createComponentTree span mean in OpenTelemetry scope #85929
-
SummaryIn my Next.js app, I enabled instrumentation through OpenTelemetry, and I'm exporting traces to AWS X-Ray. I'd like to optimise its performance, but I can't optimise what I don't understand. What does this span exactly mean? What work does Next.js do during this span? Additional informationNext.js version: 16.0.1
Opentelemetry uses @vercel/otel
Deployment environment: I'm deploying Next.js to AWS Lambda using sst v3(https://github.com/sst/sst)
NodeJS version: 22(minor version depends on what AWS Lambda uses)ExampleNo response |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
|
The span NextNodeServer.createComponentTree represents the internal work Next.js does when building the React component tree for a specific route during the rendering process. In more detail, this span covers: |
Beta Was this translation helpful? Give feedback.
-
|
From what I’ve seen in the Next.js internals, that span mainly covers the phase where Next.js resolves and constructs the React component tree, including layouts, pages, and segments — but before it actually starts rendering or triggering async data dependencies. The data-fetching for server components (for example, async calls in RSC or fetch() inside components) usually happens after the tree is built, during the render / flight generation phase, which appears under separate spans (often something like renderToReadableStream or renderToString). So in your trace, it makes sense that createComponentTree completes first, and then the spans for your backend requests start — that sequence reflects Next.js building the tree first and only then starting to stream or resolve async parts. It might be worth checking whether those fetches appear under spans related to RSC payload rendering rather than the component tree creation itself. |
Beta Was this translation helpful? Give feedback.
-
|
NextNodeServer.createComponentTree span duration depends on how complex your route’s component hierarchy and data dependencies are.
You can confirm which parts are slow by checking for gaps between getLayoutOrPageModule spans — large gaps there usually mean slow module resolution or layout initialization. |
Beta Was this translation helpful? Give feedback.
From what I’ve seen in the Next.js internals, that span mainly covers the phase where Next.js resolves and constructs the React component tree, including layouts, pages, and segments — but before it actually starts rendering or triggering async data dependencies.
The data-fetching for server components (for example, async calls in RSC or fetch() inside components) usually happens after the tree is built, during the render / flight generation phase, which appears under separate spans (often something like renderToReadableStream or renderToString).
So in your trace, it makes sense that createComponentTree completes first, and then the spans for your backend requests start — that sequence re…