DEV Community

Cover image for Analyzing .next/trace
Hans Otto Wirtz
Hans Otto Wirtz

Posted on

3

Analyzing .next/trace

If you want to analyze why your Next.js build is slow, using .next/trace is what you need. But it's not documented.

To analyze in your CLI:

Make sure to have pnpm installed.

git clone https://github.com/vercel/next.js.git && cd next.js
pnpm i
node scripts/trace-to-tree.mjs /your/app/.next/trace
Enter fullscreen mode Exit fullscreen mode

To analyze with Jaeger:

First make sure to have Docker and Cargo/Rust installed.

docker run --rm --name jaeger \
  -e COLLECTOR_ZIPKIN_HOST_PORT=:9411 \
  -p 6831:6831/udp \
  -p 6832:6832/udp \
  -p 5778:5778 \
  -p 16686:16686 \
  -p 4317:4317 \
  -p 4318:4318 \
  -p 14250:14250 \
  -p 14268:14268 \
  -p 14269:14269 \
  -p 9411:9411 \
  jaegertracing/all-in-one:1.52
Enter fullscreen mode Exit fullscreen mode
git clone https://github.com/vercel/next.js.git && cd next.js
pnpm i
cd scripts/send-to-jaeger
cargo run /your/app/.next/trace
Enter fullscreen mode Exit fullscreen mode

At the top of the output, the trace URL will be logged:

Jaeger trace will be available on http://127.0.0.1:16686/trace/ae9e5ca034dca21e
Enter fullscreen mode Exit fullscreen mode

Sources:
Tim's comments at https://github.com/vercel/next.js/issues/45529

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay