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
6eb2c246
Unverified
Commit
6eb2c246
authored
Jan 29, 2024
by
Dima Voytenko
Committed by
GitHub
Jan 29, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Telemetry: add time-to-first-byte signal (#61238)
parent
5cf4f878
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
62 additions
and
6 deletions
+62
-6
10-open-telemetry.mdx
...ding-your-application/06-optimizing/10-open-telemetry.mdx
+6
-0
constants.ts
packages/next/src/server/lib/trace/constants.ts
+2
-0
pipe-readable.ts
packages/next/src/server/pipe-readable.ts
+9
-0
opentelemetry.test.ts
test/e2e/opentelemetry/opentelemetry.test.ts
+45
-6
No files found.
docs/02-app/01-building-your-application/06-optimizing/10-open-telemetry.mdx
View file @
6eb2c246
...
...
@@ -357,3 +357,9 @@ Attributes:
-
`next.span_name`
-
`next.span_type`
-
`next.segment`
### `start response`
-
`next.span_type`
:
`NextNodeServer.startResponse`
.
This
zero
-
length
span
represents
the
time
when
the
first
byte
has
been
sent
in
the
response
.
packages/next/src/server/lib/trace/constants.ts
View file @
6eb2c246
...
...
@@ -60,6 +60,7 @@ enum NextNodeServerSpan {
renderError
=
'NextNodeServer.renderError'
,
renderErrorToHTML
=
'NextNodeServer.renderErrorToHTML'
,
render404
=
'NextNodeServer.render404'
,
startResponse
=
'NextNodeServer.startResponse'
,
// nested inner span, does not require parent scope name
route
=
'route'
,
...
...
@@ -132,6 +133,7 @@ export const NextVanillaSpanAllowlist = [
NextNodeServerSpan
.
createComponentTree
,
NextNodeServerSpan
.
findPageComponents
,
NextNodeServerSpan
.
getLayoutOrPageModule
,
NextNodeServerSpan
.
startResponse
,
]
export
{
...
...
packages/next/src/server/pipe-readable.ts
View file @
6eb2c246
...
...
@@ -5,6 +5,8 @@ import {
createAbortController
,
}
from
'./web/spec-extension/adapters/next-request'
import
{
DetachedPromise
}
from
'../lib/detached-promise'
import
{
getTracer
}
from
'./lib/trace/tracer'
import
{
NextNodeServerSpan
}
from
'./lib/trace/constants'
export
function
isAbortError
(
e
:
any
):
e
is
Error
&
{
name
:
'AbortError'
}
{
return
e
?.
name
===
'AbortError'
||
e
?.
name
===
ResponseAbortedName
...
...
@@ -47,6 +49,13 @@ function createWriterFromResponse(
if
(
!
started
)
{
started
=
true
res
.
flushHeaders
()
getTracer
().
trace
(
NextNodeServerSpan
.
startResponse
,
{
spanName
:
'start response'
,
},
()
=>
undefined
)
}
try
{
...
...
test/e2e/opentelemetry/opentelemetry.test.ts
View file @
6eb2c246
...
...
@@ -114,8 +114,8 @@ createNextDescribe(
const
numberOfRootTraces
=
env
.
span
.
rootParentId
===
undefined
?
1
:
0
const
traces
=
await
getSanitizedTraces
(
numberOfRootTraces
)
if
(
traces
.
length
<
9
)
{
return
`not enough traces, expected
9
, but got
${
traces
.
length
}
`
if
(
traces
.
length
<
10
)
{
return
`not enough traces, expected
10
, but got
${
traces
.
length
}
`
}
expect
(
traces
).
toMatchInlineSnapshot
(
`
[
...
...
@@ -226,6 +226,19 @@ createNextDescribe(
},
"traceId": "
${
env
.
span
.
traceId
}
",
},
{
"attributes": {
"next.span_name": "start response",
"next.span_type": "NextNodeServer.startResponse",
},
"kind": 0,
"name": "start response",
"parentId": "[parent-id]",
"status": {
"code": 0,
},
"traceId": "
${
env
.
span
.
traceId
}
",
},
{
"attributes": {
"next.page": "/app/[param]/layout",
...
...
@@ -267,8 +280,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
(
`
[
...
...
@@ -322,6 +335,19 @@ createNextDescribe(
},
"traceId": "
${
env
.
span
.
traceId
}
",
},
{
"attributes": {
"next.span_name": "start response",
"next.span_type": "NextNodeServer.startResponse",
},
"kind": 0,
"name": "start response",
"parentId": "[parent-id]",
"status": {
"code": 0,
},
"traceId": "
${
env
.
span
.
traceId
}
",
},
]
`
)
return
'success'
...
...
@@ -638,8 +664,8 @@ createNextDescribe(
await
check
(
async
()
=>
{
const
traces
=
await
getSanitizedTraces
(
1
)
if
(
traces
.
length
<
5
)
{
return
`not enough traces, expected
5
, but got
${
traces
.
length
}
`
if
(
traces
.
length
<
6
)
{
return
`not enough traces, expected
6
, but got
${
traces
.
length
}
`
}
expect
(
traces
).
toMatchInlineSnapshot
(
`
[
...
...
@@ -730,6 +756,19 @@ createNextDescribe(
},
"traceId": "[trace-id]",
},
{
"attributes": {
"next.span_name": "start response",
"next.span_type": "NextNodeServer.startResponse",
},
"kind": 0,
"name": "start response",
"parentId": "[parent-id]",
"status": {
"code": 0,
},
"traceId": "[trace-id]",
},
{
"attributes": {
"next.page": "/app/[param]/layout",
...
...
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