Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Instrumentation: Span BaseServer.handleRequest is missing http.route attribute #2972

@guisehn

Description

@guisehn

Hello!

We have a Next.js 15 application running on Netlify using the pages router, with OpenTelemetry (for server traces) configured.

The root span emitted for each HTTP request is BaseServer.handleRequest, and according to the documentation, it should include the following span attributes:

  • http.method (e.g. GET)
  • http.status_code (e.g. 200)
  • http.route: (e.g. /)
  • http.target: (e.g. /?foo=bar)

When I run the application locally or self-hosted (via Docker), all of these attributes are present -- including http.route.

Image

However, when running the same application on Netlify, the span attribute http.route is absent. As a result, all traces from Netlify in our observability platform (Datadog) are grouped only by HTTP method (GET, POST, etc.) rather than by method and route (GET /, GET /another-route, etc.).

Image

I’ve opened a customer support ticket with Netlify, but since this appears to be a platform interoperability issue, I thought it would be helpful to open an issue here as well.

From what I can see, Next.js sets the http.route attribute inside an if block:

https://github.com/vercel/next.js/blob/e2a237abf2d1a4843a748df23256e89c14684198/packages/next/src/server/base-server.ts#L971

It seems that when running on Netlify, if (route) evaluates to false, so the else block is executed instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions