Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
0df7ea0d
Commit
0df7ea0d
authored
Mar 17, 2025
by
Evan Kirkiles
Committed by
devjiwonchoi
Aug 29, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use route matcher's pathname for app route spans, not manual derivation
parent
6fd885cf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
18 deletions
+15
-18
module.ts
packages/next/src/server/route-modules/app-route/module.ts
+4
-7
opentelemetry.test.ts
test/e2e/opentelemetry/instrumentation/opentelemetry.test.ts
+11
-11
No files found.
packages/next/src/server/route-modules/app-route/module.ts
View file @
0df7ea0d
...
@@ -22,7 +22,6 @@ import { getImplicitTags, type ImplicitTags } from '../../lib/implicit-tags'
...
@@ -22,7 +22,6 @@ import { getImplicitTags, type ImplicitTags } from '../../lib/implicit-tags'
import
{
patchFetch
}
from
'../../lib/patch-fetch'
import
{
patchFetch
}
from
'../../lib/patch-fetch'
import
{
getTracer
}
from
'../../lib/trace/tracer'
import
{
getTracer
}
from
'../../lib/trace/tracer'
import
{
AppRouteRouteHandlersSpan
}
from
'../../lib/trace/constants'
import
{
AppRouteRouteHandlersSpan
}
from
'../../lib/trace/constants'
import
{
getPathnameFromAbsolutePath
}
from
'./helpers/get-pathname-from-absolute-path'
import
*
as
Log
from
'../../../build/output/log'
import
*
as
Log
from
'../../../build/output/log'
import
{
autoImplementMethods
}
from
'./helpers/auto-implement-methods'
import
{
autoImplementMethods
}
from
'./helpers/auto-implement-methods'
import
{
import
{
...
@@ -765,20 +764,18 @@ export class AppRouteRouteModule extends RouteModule<
...
@@ -765,20 +764,18 @@ export class AppRouteRouteModule extends RouteModule<
this
.
dynamic
satisfies
never
this
.
dynamic
satisfies
never
}
}
// TODO: propagate this pathname from route matcher
const
route
=
getPathnameFromAbsolutePath
(
this
.
resolvedPagePath
)
const
tracer
=
getTracer
()
const
tracer
=
getTracer
()
// Update the root span attribute for the route.
// Update the root span attribute for the route.
tracer
.
setRootSpanAttribute
(
'next.route'
,
route
)
const
{
pathname
}
=
this
.
definition
tracer
.
setRootSpanAttribute
(
'next.route'
,
pathname
)
return
tracer
.
trace
(
return
tracer
.
trace
(
AppRouteRouteHandlersSpan
.
runHandler
,
AppRouteRouteHandlersSpan
.
runHandler
,
{
{
spanName
:
`executing api route (app)
${
rout
e
}
`
,
spanName
:
`executing api route (app)
${
pathnam
e
}
`
,
attributes
:
{
attributes
:
{
'next.route'
:
rout
e
,
'next.route'
:
pathnam
e
,
},
},
},
},
async
()
=>
async
()
=>
...
...
test/e2e/opentelemetry/instrumentation/opentelemetry.test.ts
View file @
0df7ea0d
...
@@ -13,7 +13,7 @@ const EXTERNAL = {
...
@@ -13,7 +13,7 @@ const EXTERNAL = {
const
COLLECTOR_PORT
=
9001
const
COLLECTOR_PORT
=
9001
describe
(
'opentelemetry'
,
()
=>
{
describe
(
'opentelemetry'
,
()
=>
{
const
{
next
,
skipped
,
isNext
Dev
,
isNext
Start
}
=
nextTestSetup
({
const
{
next
,
skipped
,
isNextStart
}
=
nextTestSetup
({
files
:
__dirname
,
files
:
__dirname
,
skipDeployment
:
true
,
skipDeployment
:
true
,
dependencies
:
require
(
'./package.json'
).
dependencies
,
dependencies
:
require
(
'./package.json'
).
dependencies
,
...
@@ -394,14 +394,14 @@ describe('opentelemetry', () => {
...
@@ -394,14 +394,14 @@ describe('opentelemetry', () => {
await
expectTrace
(
getCollector
(),
[
await
expectTrace
(
getCollector
(),
[
{
{
name
:
'GET /api/app/[param]/data
/route
'
,
name
:
'GET /api/app/[param]/data'
,
attributes
:
{
attributes
:
{
'http.method'
:
'GET'
,
'http.method'
:
'GET'
,
'http.route'
:
'/api/app/[param]/data
/route
'
,
'http.route'
:
'/api/app/[param]/data'
,
'http.status_code'
:
200
,
'http.status_code'
:
200
,
'http.target'
:
'/api/app/param/data'
,
'http.target'
:
'/api/app/param/data'
,
'next.route'
:
'/api/app/[param]/data
/route
'
,
'next.route'
:
'/api/app/[param]/data'
,
'next.span_name'
:
'GET /api/app/[param]/data
/route
'
,
'next.span_name'
:
'GET /api/app/[param]/data'
,
'next.span_type'
:
'BaseServer.handleRequest'
,
'next.span_type'
:
'BaseServer.handleRequest'
,
},
},
kind
:
1
,
kind
:
1
,
...
@@ -410,11 +410,11 @@ describe('opentelemetry', () => {
...
@@ -410,11 +410,11 @@ describe('opentelemetry', () => {
parentId
:
env
.
span
.
rootParentId
,
parentId
:
env
.
span
.
rootParentId
,
spans
:
[
spans
:
[
{
{
name
:
'executing api route (app) /api/app/[param]/data
/route
'
,
name
:
'executing api route (app) /api/app/[param]/data'
,
attributes
:
{
attributes
:
{
'next.route'
:
'/api/app/[param]/data
/route
'
,
'next.route'
:
'/api/app/[param]/data'
,
'next.span_name'
:
'next.span_name'
:
'executing api route (app) /api/app/[param]/data
/route
'
,
'executing api route (app) /api/app/[param]/data'
,
'next.span_type'
:
'AppRouteRouteHandlers.runHandler'
,
'next.span_type'
:
'AppRouteRouteHandlers.runHandler'
,
},
},
kind
:
0
,
kind
:
0
,
...
@@ -452,11 +452,11 @@ describe('opentelemetry', () => {
...
@@ -452,11 +452,11 @@ describe('opentelemetry', () => {
runtime
:
'edge'
,
runtime
:
'edge'
,
traceId
:
env
.
span
.
traceId
,
traceId
:
env
.
span
.
traceId
,
parentId
:
env
.
span
.
rootParentId
,
parentId
:
env
.
span
.
rootParentId
,
name
:
'executing api route (app) /api/app/[param]/data/edge
/route
'
,
name
:
'executing api route (app) /api/app/[param]/data/edge'
,
attributes
:
{
attributes
:
{
'next.route'
:
'/api/app/[param]/data/edge
/route
'
,
'next.route'
:
'/api/app/[param]/data/edge'
,
'next.span_name'
:
'next.span_name'
:
'executing api route (app) /api/app/[param]/data/edge
/route
'
,
'executing api route (app) /api/app/[param]/data/edge'
,
'next.span_type'
:
'AppRouteRouteHandlers.runHandler'
,
'next.span_type'
:
'AppRouteRouteHandlers.runHandler'
,
},
},
kind
:
0
,
kind
:
0
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment