Skip to content

Duplicate request traces for a single request #124

@cbodin

Description

@cbodin

Each request to the Next.js application will send 2 traces. This seems to be related to the internal request routing as the operation.name differs and the first trace shows the actual path and the second trace shows the matched route.

E.g. in ApplicationInsights:
image

For example, a catch-all page that triggers a notFound() will show the first trace as successful and the second (correctly) as unsuccessful.

Request properties:

Attribute Trace 1 value Trace 2 value
Event time 9/18/2024, 2:40:09.999 PM (Local time) 9/18/2024, 2:40:10.117 PM (Local time)
Name GET /this-page-does-not-exist GET /[locale]/[[...slug]]
Response code 200 404
Successful request true false
Response time 61.3 ms 1.4 s

Custom properties:

Attribute Trace 1 value Trace 2 value
next.span_name GET /this-page-does-not-exist GET /[locale]/[[...slug]]
next.span_type BaseServer.handleRequest BaseServer.handleRequest
http.target /this-page-does-not-exist /this-page-does-not-exist
next.rsc false false
next.route N/A /[locale]/[[...slug]]
next.bubble true N/A
operation.name next_js.BaseServer.handleRequest web.request
resource.name N/A GET /[locale]/[[...slug]]

Package Version
next 14.2.3
@vercel/otel 1.10.0
@opentelemetry/api 1.9.0
@azure/monitor-opentelemetry-exporter 1.0.0-beta.26

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions