Unverified Commit 0c1741c4 authored by Dima Voytenko's avatar Dima Voytenko Committed by GitHub

Telemetry code load (#60594)

The following spans are either added or displayed by default:

* `NextNodeServer.findPageComponents` - page components
resolution/require
* `NextNodeServer.getLayoutOrPageModule` - load modules (webpack or
turbopack)
parent b805180f
......@@ -337,3 +337,27 @@ Attributes:
- `next.span_name`
- `next.span_type`
- `next.page`
### `resolve page components`
- `next.span_type`: `NextNodeServer.findPageComponents`.
This span represents the process of resolving page components for a specific page.
Attributes:
- `next.span_name`
- `next.span_type`
- `next.route`
### `resolve segment modules`
- `next.span_type`: `NextNodeServer.getLayoutOrPageModule`.
This span represents loading of code modules for a layout or a page.
Attributes:
- `next.span_name`
- `next.span_type`
- `next.segment`
......@@ -11,6 +11,8 @@ import { getLayerAssets } from './get-layer-assets'
import { hasLoadingComponentInTree } from './has-loading-component-in-tree'
import { validateRevalidate } from '../lib/patch-fetch'
import { PARALLEL_ROUTE_DEFAULT_PATH } from '../../client/components/parallel-route-default'
import { getTracer } from '../lib/trace/tracer'
import { NextNodeServerSpan } from '../lib/trace/constants'
type ComponentTree = {
seedData: CacheNodeSeedData
......@@ -131,7 +133,17 @@ export async function createComponentTree({
const isLayout = typeof layout !== 'undefined'
const isPage = typeof page !== 'undefined'
const [layoutOrPageMod] = await getLayoutOrPageModule(tree)
const [layoutOrPageMod] = await getTracer().trace(
NextNodeServerSpan.getLayoutOrPageModule,
{
hideSpan: !(isLayout || isPage),
spanName: 'resolve segment modules',
attributes: {
'next.segment': segment,
},
},
() => getLayoutOrPageModule(tree)
)
/**
* Checks if the current segment is a root layout.
......
......@@ -38,6 +38,7 @@ enum NextServerSpan {
enum NextNodeServerSpan {
compression = 'NextNodeServer.compression',
getBuildId = 'NextNodeServer.getBuildId',
getLayoutOrPageModule = 'NextNodeServer.getLayoutOrPageModule',
generateStaticRoutes = 'NextNodeServer.generateStaticRoutes',
generateFsStaticRoutes = 'NextNodeServer.generateFsStaticRoutes',
generatePublicRoutes = 'NextNodeServer.generatePublicRoutes',
......@@ -127,6 +128,8 @@ export const NextVanillaSpanAllowlist = [
AppRouteRouteHandlersSpan.runHandler,
ResolveMetadataSpan.generateMetadata,
ResolveMetadataSpan.generateViewport,
NextNodeServerSpan.findPageComponents,
NextNodeServerSpan.getLayoutOrPageModule,
]
export {
......
......@@ -141,6 +141,7 @@ interface NextTracer {
type NextAttributeNames =
| 'next.route'
| 'next.page'
| 'next.segment'
| 'next.span_name'
| 'next.span_type'
type OTELAttributeNames = `http.${string}` | `net.${string}`
......
......@@ -658,7 +658,7 @@ export default class NextNodeServer extends BaseServer {
return getTracer().trace(
NextNodeServerSpan.findPageComponents,
{
spanName: `resolving page into components`,
spanName: 'resolve page components',
attributes: {
'next.route': isAppPath ? normalizeAppPath(page) : page,
},
......
......@@ -114,8 +114,8 @@ createNextDescribe(
const numberOfRootTraces =
env.span.rootParentId === undefined ? 1 : 0
const traces = await getSanitizedTraces(numberOfRootTraces)
if (traces.length < 5) {
return `not enough traces, expected 5, but got ${traces.length}`
if (traces.length < 8) {
return `not enough traces, expected 8, but got ${traces.length}`
}
expect(traces).toMatchInlineSnapshot(`
[
......@@ -171,6 +171,48 @@ createNextDescribe(
},
"traceId": "${env.span.traceId}",
},
{
"attributes": {
"next.route": "/app/[param]/rsc-fetch",
"next.span_name": "resolve page components",
"next.span_type": "NextNodeServer.findPageComponents",
},
"kind": 0,
"name": "resolve page components",
"parentId": "[parent-id]",
"status": {
"code": 0,
},
"traceId": "${env.span.traceId}",
},
{
"attributes": {
"next.segment": "[param]",
"next.span_name": "resolve segment modules",
"next.span_type": "NextNodeServer.getLayoutOrPageModule",
},
"kind": 0,
"name": "resolve segment modules",
"parentId": "[parent-id]",
"status": {
"code": 0,
},
"traceId": "${env.span.traceId}",
},
{
"attributes": {
"next.segment": "__PAGE__",
"next.span_name": "resolve segment modules",
"next.span_type": "NextNodeServer.getLayoutOrPageModule",
},
"kind": 0,
"name": "resolve segment modules",
"parentId": "[parent-id]",
"status": {
"code": 0,
},
"traceId": "${env.span.traceId}",
},
{
"attributes": {
"next.page": "/app/[param]/layout",
......@@ -212,8 +254,8 @@ createNextDescribe(
const numberOfRootTraces =
env.span.rootParentId === undefined ? 1 : 0
const traces = await getSanitizedTraces(numberOfRootTraces)
if (traces.length < 2) {
return `not enough traces, expected 2, but got ${traces.length}`
if (traces.length < 3) {
return `not enough traces, expected 3, but got ${traces.length}`
}
expect(traces).toMatchInlineSnapshot(`
[
......@@ -253,6 +295,20 @@ createNextDescribe(
},
"traceId": "${env.span.traceId}",
},
{
"attributes": {
"next.route": "/api/app/[param]/data",
"next.span_name": "resolve page components",
"next.span_type": "NextNodeServer.findPageComponents",
},
"kind": 0,
"name": "resolve page components",
"parentId": "[parent-id]",
"status": {
"code": 0,
},
"traceId": "${env.span.traceId}",
},
]
`)
return 'success'
......@@ -268,8 +324,8 @@ createNextDescribe(
const numberOfRootTraces =
env.span.rootParentId === undefined ? 1 : 0
const traces = await getSanitizedTraces(numberOfRootTraces)
if (traces.length < 3) {
return `not enough traces, expected 3, but got ${traces.length}`
if (traces.length < 4) {
return `not enough traces, expected 4, but got ${traces.length}`
}
expect(traces).toMatchInlineSnapshot(`
[
......@@ -295,6 +351,20 @@ createNextDescribe(
},
"traceId": "${env.span.traceId}",
},
{
"attributes": {
"next.route": "/pages/[param]/getServerSideProps",
"next.span_name": "resolve page components",
"next.span_type": "NextNodeServer.findPageComponents",
},
"kind": 0,
"name": "resolve page components",
"parentId": "[parent-id]",
"status": {
"code": 0,
},
"traceId": "${env.span.traceId}",
},
{
"attributes": {
"next.route": "/pages/[param]/getServerSideProps",
......@@ -337,8 +407,8 @@ createNextDescribe(
const numberOfRootTraces =
env.span.rootParentId === undefined ? 1 : 0
const traces = await getSanitizedTraces(numberOfRootTraces)
if (traces.length < 3) {
return `not enough traces, expected 3, but got ${traces.length}`
if (traces.length < 4) {
return `not enough traces, expected 4, but got ${traces.length}`
}
expect(traces).toMatchInlineSnapshot(`
[
......@@ -364,6 +434,20 @@ createNextDescribe(
},
"traceId": "${env.span.traceId}",
},
{
"attributes": {
"next.route": "/pages/[param]/getStaticProps${v}",
"next.span_name": "resolve page components",
"next.span_type": "NextNodeServer.findPageComponents",
},
"kind": 0,
"name": "resolve page components",
"parentId": "[parent-id]",
"status": {
"code": 0,
},
"traceId": "${env.span.traceId}",
},
{
"attributes": {
"next.route": "/pages/[param]/getStaticProps${v}",
......@@ -578,6 +662,48 @@ createNextDescribe(
},
"traceId": "[trace-id]",
},
{
"attributes": {
"next.route": "/app/[param]/rsc-fetch",
"next.span_name": "resolve page components",
"next.span_type": "NextNodeServer.findPageComponents",
},
"kind": 0,
"name": "resolve page components",
"parentId": "[parent-id]",
"status": {
"code": 0,
},
"traceId": "[trace-id]",
},
{
"attributes": {
"next.segment": "[param]",
"next.span_name": "resolve segment modules",
"next.span_type": "NextNodeServer.getLayoutOrPageModule",
},
"kind": 0,
"name": "resolve segment modules",
"parentId": "[parent-id]",
"status": {
"code": 0,
},
"traceId": "[trace-id]",
},
{
"attributes": {
"next.segment": "__PAGE__",
"next.span_name": "resolve segment modules",
"next.span_type": "NextNodeServer.getLayoutOrPageModule",
},
"kind": 0,
"name": "resolve segment modules",
"parentId": "[parent-id]",
"status": {
"code": 0,
},
"traceId": "[trace-id]",
},
{
"attributes": {
"next.page": "/app/[param]/layout",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment