Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/next/src/build/templates/app-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ export async function handler(
})
span.updateName(name)
} else {
span.updateName(`${method} ${req.url}`)
span.updateName(`${method}`)
}
})
}
Expand Down Expand Up @@ -1396,7 +1396,7 @@ export async function handler(
tracer.trace(
BaseServerSpan.handleRequest,
{
spanName: `${method} ${req.url}`,
spanName: `${method}`,
kind: SpanKind.SERVER,
attributes: {
'http.method': method,
Expand Down
4 changes: 2 additions & 2 deletions packages/next/src/build/templates/app-route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ export async function handler(
})
span.updateName(name)
} else {
span.updateName(`${method} ${req.url}`)
span.updateName(`${method}`)
}
})
}
Expand Down Expand Up @@ -454,7 +454,7 @@ export async function handler(
tracer.trace(
BaseServerSpan.handleRequest,
{
spanName: `${method} ${req.url}`,
spanName: `${method}`,
kind: SpanKind.SERVER,
attributes: {
'http.method': method,
Expand Down
4 changes: 2 additions & 2 deletions packages/next/src/build/templates/edge-ssr-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ async function requestHandler(
})
span.updateName(name)
} else {
span.updateName(`${req.method} ${relativeUrl}`)
span.updateName(`${req.method}`)
}
})

Expand All @@ -340,7 +340,7 @@ async function requestHandler(
tracer.trace(
BaseServerSpan.handleRequest,
{
spanName: `${req.method} ${relativeUrl}`,
spanName: `${req.method}`,
kind: SpanKind.SERVER,
attributes: {
'http.method': req.method,
Expand Down
4 changes: 2 additions & 2 deletions packages/next/src/build/templates/edge-ssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ async function requestHandler(
})
span.updateName(name)
} else {
span.updateName(`${req.method} ${relativeUrl}`)
span.updateName(`${req.method}`)
}
})

Expand Down Expand Up @@ -343,7 +343,7 @@ async function requestHandler(
tracer.trace(
BaseServerSpan.handleRequest,
{
spanName: `${req.method} ${relativeUrl}`,
spanName: `${req.method}`,
kind: SpanKind.SERVER,
attributes: {
'http.method': req.method,
Expand Down
4 changes: 2 additions & 2 deletions packages/next/src/build/templates/pages-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export async function handler(
})
span.updateName(name)
} else {
span.updateName(`${method} ${req.url}`)
span.updateName(`${method}`)
}
})

Expand All @@ -146,7 +146,7 @@ export async function handler(
tracer.trace(
BaseServerSpan.handleRequest,
{
spanName: `${method} ${req.url}`,
spanName: `${method}`,
kind: SpanKind.SERVER,
attributes: {
'http.method': method,
Expand Down
10 changes: 3 additions & 7 deletions packages/next/src/server/base-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -882,13 +882,13 @@ export default abstract class Server<
): Promise<void> {
await this.prepare()
const method = req.method.toUpperCase()

const tracer = getTracer()

return tracer.withPropagatedContext(req.headers, () => {
return tracer.trace(
BaseServerSpan.handleRequest,
{
spanName: `${method} ${req.url}`,
spanName: `${method}`,
kind: SpanKind.SERVER,
attributes: {
'http.method': method,
Expand Down Expand Up @@ -944,11 +944,7 @@ export default abstract class Server<
})
span.updateName(name)
} else {
span.updateName(
isRSCRequest
? `RSC ${method} ${req.url}`
: `${method} ${req.url}`
)
span.updateName(isRSCRequest ? `RSC ${method}` : `${method}`)
}
})
)
Expand Down
16 changes: 8 additions & 8 deletions test/e2e/opentelemetry/instrumentation/opentelemetry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,10 @@ describe('opentelemetry', () => {
traceId: env.span.traceId,
parentId: env.span.rootParentId,
runtime: 'nodejs',
name: 'GET /app/param/rsc-fetch/edge',
name: 'GET',
kind: 1,
attributes: {
'next.span_name': 'GET /app/param/rsc-fetch/edge',
'next.span_name': 'GET',
'next.span_type': 'BaseServer.handleRequest',
'http.method': 'GET',
'http.target': '/app/param/rsc-fetch/edge',
Expand Down Expand Up @@ -468,10 +468,10 @@ describe('opentelemetry', () => {
runtime: 'nodejs',
traceId: env.span.traceId,
parentId: env.span.rootParentId,
name: 'GET /api/app/param/data/edge',
name: 'GET',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this one not GET /api/app/[param]/data/edge`?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

next.route is not available at this point, which is measured in the very beginning of the request. We might remove it as we doubt if this span is helpful.

spanName: `${method}`,

cc @ijjk who has more context

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

next.route should always be available by the end of the span. So it should be available here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah these spans are never updated because it's next-server crossing to the edge runtime. The comment above in the test even calls out wondering why we're asserting it being there. It would also only be present locally with next start since edge runtime when deployed wouldn't use next-server.

kind: 1,
attributes: {
'next.span_name': 'GET /api/app/param/data/edge',
'next.span_name': 'GET',
'next.span_type': 'BaseServer.handleRequest',
'http.method': 'GET',
'http.target': '/api/app/param/data/edge',
Expand Down Expand Up @@ -831,10 +831,10 @@ describe('opentelemetry', () => {
runtime: 'nodejs',
traceId: env.span.traceId,
parentId: env.span.rootParentId,
name: 'GET /pages/param/edge/getServerSideProps',
name: 'GET',
kind: 1,
attributes: {
'next.span_name': 'GET /pages/param/edge/getServerSideProps',
'next.span_name': 'GET',
'next.span_type': 'BaseServer.handleRequest',
'http.method': 'GET',
'http.target': '/pages/param/edge/getServerSideProps',
Expand Down Expand Up @@ -1100,10 +1100,10 @@ describe('opentelemetry', () => {
runtime: 'nodejs',
traceId: env.span.traceId,
parentId: env.span.rootParentId,
name: 'GET /api/pages/param/edge',
name: 'GET',
kind: 1,
attributes: {
'next.span_name': 'GET /api/pages/param/edge',
'next.span_name': 'GET',
'next.span_type': 'BaseServer.handleRequest',
'http.method': 'GET',
'http.target': '/api/pages/param/edge',
Expand Down
Loading