Skip to content

High-cardinality HTTP span names #54694

@BarryThePenguin

Description

@BarryThePenguin

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 22.6.0: Wed Jul  5 22:22:05 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6000
    Binaries:
      Node: 18.17.1
      npm: 9.8.1
      Yarn: 1.22.19
      pnpm: N/A
    Relevant Packages:
      next: 13.4.12
      eslint-config-next: 13.4.12
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 5.1.6
    Next.js Config:
      output: standalone

Which area(s) of Next.js are affected? (leave empty if unsure)

Middleware / Edge (API routes, runtime), Routing (next/router, next/navigation, next/link), Standalone mode (output: "standalone")

Link to the code that reproduces this issue or a replay of the bug

https://github.com/BarryThePenguin/nextjs-otel-high-cardinality

To Reproduce

Describe the Bug

Operations collected include dynamic segments values, which makes grouping similar spans impossible

The issue is similar to this topic open-telemetry/opentelemetry-js#897

This is what we see in Jaeger

image

Note that the operation select input incudes GET /legacy/vercel/next.js

Expected Behavior

According to the linked OpenTelemetry issue, I'd expect to see the operation name to be GET /legacy/[...repoName], or something similar

Names are not meant to uniquely identify a trace, but a class of traces. for instance, GET /user/:id is a good name, but GET /user/123 is bad because you can't easily search for all traces for the same route.

It's also pointed out in the linked issue that the spec mentions

Instrumentation MUST NOT default to using URI path as span name, but MAY provide hooks to allow custom logic to override the default span name.
https://opentelemetry.io/docs/specs/otel/trace/semantic_conventions/http/

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

output standalone + k8s

Metadata

Metadata

Assignees

No one assigned

    Labels

    InstrumentationRelated to Next.js Instrumentation.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions