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
1f788b54
Unverified
Commit
1f788b54
authored
Sep 15, 2021
by
Tim Neutkens
Committed by
GitHub
Sep 15, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Development tracing improvements (#29076)
parent
85b83998
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
68 additions
and
18 deletions
+68
-18
package.json
bench/nested-deps/package.json
+1
-1
profiling-plugin.ts
packages/next/build/webpack/plugins/profiling-plugin.ts
+39
-9
taskfile.js
packages/next/taskfile.js
+1
-1
to-jaeger.ts
packages/next/trace/report/to-jaeger.ts
+1
-1
trace.ts
packages/next/trace/trace.ts
+26
-6
No files found.
bench/nested-deps/package.json
View file @
1f788b54
{
{
"scripts"
:
{
"scripts"
:
{
"prepare"
:
"rm -rf components && node ./fuzzponent.js -d 2 -s 206 -o components"
,
"prepare"
:
"rm -rf components &&
mkdir components &&
node ./fuzzponent.js -d 2 -s 206 -o components"
,
"dev"
:
"../../node_modules/.bin/next dev"
,
"dev"
:
"../../node_modules/.bin/next dev"
,
"build"
:
"../../node_modules/.bin/next build"
,
"build"
:
"../../node_modules/.bin/next build"
,
"start"
:
"../../node_modules/.bin/next start"
,
"start"
:
"../../node_modules/.bin/next start"
,
...
...
packages/next/build/webpack/plugins/profiling-plugin.ts
View file @
1f788b54
...
@@ -99,15 +99,22 @@ export class ProfilingPlugin {
...
@@ -99,15 +99,22 @@ export class ProfilingPlugin {
}
}
traceCompilationHooks
(
compiler
:
any
)
{
traceCompilationHooks
(
compiler
:
any
)
{
this
.
traceHookPair
(
this
.
traceHookPair
(
'emit'
,
compiler
.
hooks
.
emit
,
compiler
.
hooks
.
afterEmit
,
{
'webpack-emit'
,
parentSpan
:
()
=>
compiler
.
hooks
.
emit
,
webpackInvalidSpans
.
get
(
compiler
)
||
this
.
runWebpackSpan
,
compiler
.
hooks
.
afterEmit
,
})
{
parentSpan
:
()
=>
if
(
isWebpack5
)
{
webpackInvalidSpans
.
get
(
compiler
)
||
this
.
runWebpackSpan
,
this
.
traceHookPair
(
}
'make'
,
)
compiler
.
hooks
.
make
,
compiler
.
hooks
.
finishMake
,
{
parentSpan
:
()
=>
webpackInvalidSpans
.
get
(
compiler
)
||
this
.
runWebpackSpan
,
}
)
}
compiler
.
hooks
.
compilation
.
tap
(
pluginName
,
(
compilation
:
any
)
=>
{
compiler
.
hooks
.
compilation
.
tap
(
pluginName
,
(
compilation
:
any
)
=>
{
compilation
.
hooks
.
buildModule
.
tap
(
pluginName
,
(
module
:
any
)
=>
{
compilation
.
hooks
.
buildModule
.
tap
(
pluginName
,
(
module
:
any
)
=>
{
...
@@ -152,6 +159,29 @@ export class ProfilingPlugin {
...
@@ -152,6 +159,29 @@ export class ProfilingPlugin {
spans
.
get
(
module
)?.
stop
()
spans
.
get
(
module
)?.
stop
()
})
})
if
(
isWebpack5
)
{
this
.
traceHookPair
(
'webpack-compilation-seal'
,
compilation
.
hooks
.
seal
,
compilation
.
hooks
.
afterSeal
,
{
parentSpan
:
()
=>
spans
.
get
(
compiler
)
!
}
)
this
.
traceHookPair
(
'add-entry'
,
compilation
.
hooks
.
addEntry
,
compilation
.
hooks
.
afterSeal
,
{
attrs
:
(
entry
:
any
)
=>
{
return
{
request
:
entry
.
request
,
}
},
parentSpan
:
()
=>
spans
.
get
(
compiler
)
!
,
}
)
}
this
.
traceHookPair
(
this
.
traceHookPair
(
'webpack-compilation-chunk-graph'
,
'webpack-compilation-chunk-graph'
,
compilation
.
hooks
.
beforeChunks
,
compilation
.
hooks
.
beforeChunks
,
...
...
packages/next/taskfile.js
View file @
1f788b54
...
@@ -89,7 +89,7 @@ export async function ncc_amp_optimizer(task, opts) {
...
@@ -89,7 +89,7 @@ export async function ncc_amp_optimizer(task, opts) {
.
target
(
'dist/compiled/@ampproject/toolbox-optimizer'
)
.
target
(
'dist/compiled/@ampproject/toolbox-optimizer'
)
}
}
// eslint-disable-next-line camelcase
// eslint-disable-next-line camelcase
externals
[
'arg'
]
=
'
dist
compiled/arg'
externals
[
'arg'
]
=
'
next/dist/
compiled/arg'
export
async
function
ncc_arg
(
task
,
opts
)
{
export
async
function
ncc_arg
(
task
,
opts
)
{
await
task
await
task
.
source
(
opts
.
src
||
relative
(
__dirname
,
require
.
resolve
(
'arg'
)))
.
source
(
opts
.
src
||
relative
(
__dirname
,
require
.
resolve
(
'arg'
)))
...
...
packages/next/trace/report/to-jaeger.ts
View file @
1f788b54
...
@@ -43,7 +43,7 @@ const reportToLocalHost = (
...
@@ -43,7 +43,7 @@ const reportToLocalHost = (
// Ensure ECONNRESET error is retried 3 times before erroring out
// Ensure ECONNRESET error is retried 3 times before erroring out
return
retry
(
return
retry
(
()
=>
()
=>
// Send events to
zipkin
// Send events to
jaeger's zipkin endpoint
fetch
(
zipkinAPI
,
{
fetch
(
zipkinAPI
,
{
method
:
'POST'
,
method
:
'POST'
,
headers
:
{
'Content-Type'
:
'application/json'
},
headers
:
{
'Content-Type'
:
'application/json'
},
...
...
packages/next/trace/trace.ts
View file @
1f788b54
...
@@ -23,22 +23,32 @@ export class Span {
...
@@ -23,22 +23,32 @@ export class Span {
_start
:
bigint
_start
:
bigint
constructor
(
name
:
string
,
parentId
?:
SpanId
,
attrs
?:
Object
)
{
constructor
({
name
,
parentId
,
attrs
,
startTime
,
}:
{
name
:
string
parentId
?:
SpanId
startTime
?:
bigint
attrs
?:
Object
})
{
this
.
name
=
name
this
.
name
=
name
this
.
parentId
=
parentId
this
.
parentId
=
parentId
this
.
duration
=
null
this
.
duration
=
null
this
.
attrs
=
attrs
?
{
...
attrs
}
:
{}
this
.
attrs
=
attrs
?
{
...
attrs
}
:
{}
this
.
status
=
SpanStatus
.
Started
this
.
status
=
SpanStatus
.
Started
this
.
id
=
getId
()
this
.
id
=
getId
()
this
.
_start
=
process
.
hrtime
.
bigint
()
this
.
_start
=
startTime
||
process
.
hrtime
.
bigint
()
}
}
// Durations are reported as microseconds. This gives 1000x the precision
// Durations are reported as microseconds. This gives 1000x the precision
// of something like Date.now(), which reports in milliseconds.
// of something like Date.now(), which reports in milliseconds.
// Additionally, ~285 years can be safely represented as microseconds as
// Additionally, ~285 years can be safely represented as microseconds as
// a float64 in both JSON and JavaScript.
// a float64 in both JSON and JavaScript.
stop
()
{
stop
(
stopTime
?:
bigint
)
{
const
end
:
bigint
=
process
.
hrtime
.
bigint
()
const
end
:
bigint
=
stopTime
||
process
.
hrtime
.
bigint
()
const
duration
=
(
end
-
this
.
_start
)
/
NUM_OF_MICROSEC_IN_SEC
const
duration
=
(
end
-
this
.
_start
)
/
NUM_OF_MICROSEC_IN_SEC
this
.
status
=
SpanStatus
.
Stopped
this
.
status
=
SpanStatus
.
Stopped
if
(
duration
>
Number
.
MAX_SAFE_INTEGER
)
{
if
(
duration
>
Number
.
MAX_SAFE_INTEGER
)
{
...
@@ -56,7 +66,17 @@ export class Span {
...
@@ -56,7 +66,17 @@ export class Span {
}
}
traceChild
(
name
:
string
,
attrs
?:
Object
)
{
traceChild
(
name
:
string
,
attrs
?:
Object
)
{
return
new
Span
(
name
,
this
.
id
,
attrs
)
return
new
Span
({
name
,
parentId
:
this
.
id
,
attrs
})
}
manualTraceChild
(
name
:
string
,
startTime
:
bigint
,
stopTime
:
bigint
,
attrs
?:
Object
)
{
const
span
=
new
Span
({
name
,
parentId
:
this
.
id
,
attrs
,
startTime
})
span
.
stop
(
stopTime
)
}
}
setAttribute
(
key
:
string
,
value
:
any
)
{
setAttribute
(
key
:
string
,
value
:
any
)
{
...
@@ -81,7 +101,7 @@ export class Span {
...
@@ -81,7 +101,7 @@ export class Span {
}
}
export
const
trace
=
(
name
:
string
,
parentId
?:
SpanId
,
attrs
?:
Object
)
=>
{
export
const
trace
=
(
name
:
string
,
parentId
?:
SpanId
,
attrs
?:
Object
)
=>
{
return
new
Span
(
name
,
parentId
,
attrs
)
return
new
Span
(
{
name
,
parentId
,
attrs
}
)
}
}
export
const
flushAllTraces
=
()
=>
reporter
.
flushAll
()
export
const
flushAllTraces
=
()
=>
reporter
.
flushAll
()
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