Implementing OpenTelemetry without Custom-Server in NextJS

TLDR Lex asked how to implement open telemetry without using custom-server in NextJS. vishal-signoz suggested importing and initializing tracing.js in the main file as the solution.

Powered by Struct AI
Jun 24, 2023 (5 months ago)
Photo of md5-674b77b7ab2a0ff7cfad0d756f5be745
12:14 AM
According to this post, after implementing OpenTelemetry, I can spin up the service with:
node tracing.js

From this post, the custom-server method will remove important optimizations, that's why I am wondering if there is a way to implement open telemetry without this custom-server? Because for production, the app is running with:
next build
next start -p $PORT

How to build the app and use tracing.js as an entrypoint with the build version? For node-js, I can use the following code in node.js
node -r tracing.js index.js

can I achieve a similar goal with NextJS?
Jun 27, 2023 (5 months ago)
Photo of md5-f936d3e5743d23344d6c60813189716f
03:20 AM
You can initialize tracing.js in your main file
03:21 AM
> So you need to import tracing.js in your main application. The import ./tracing.js should be the first line of your application code and initialize it before any other function. Here’s the sample github repo which shows the implementation.