Next.js endpoint tracing would be very useful.
We have found some success using an Next.js custom server with Express and dd-trace, but since Next.js has it's own router to map paths to routes, it does not report the endpoint in Datadog, meaning it's only grouped by method.
We are facing the same problem
We are using the following workaround:
ddtrace.init(...)
.use('express', {
hooks: {
request: (span, req, res) => {
if (!span || !req || !res) {
return;
}
let route;
if (res.locals.route) {
route = res.locals.route;
} else if (req.path.startsWith('/static/')) {
route = '/static/';
} else if (req.path.startsWith('/_next/')) {
route = '/_next/';
} else {
route = req.path;
}
span.setTag('resource.name', `${req.method} ${route}`);
},
},
});
```
and then in `App.getInitialProps`, we have this:
```javascript
// keep track of route, used for sending to Datadog APM
res.locals.route = ctx.pathname;
This would be very useful!
We're also facing the same issue and investigating traces is very confusing due to the resource names only containing the method.
We're also facing the same issue.
@mcuelenaere I've tried your method but for some reason it didn't work for me. Could you tell me please if you are adding ddTraceJs using express-opentracing or something else?
Most helpful comment
We're also facing the same issue.