Skip to content

Commit

Permalink
Add relationship between issuer and module to traces
Browse files Browse the repository at this point in the history
Sets the parent span for module traces to the module that caused this current module to compile, this makes tracing why a module was compiled much simpler. Also added `NEXT_WEBPACK_PARALLELISM` to allow for better traces of individual modules, this should only be used in combination with tracing.
  • Loading branch information
timneutkens committed Aug 17, 2021
1 parent 71cecc2 commit 505640d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/next/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,7 @@ export default async function getBaseWebpackConfig(
const emacsLockfilePattern = '**/.#*'

let webpackConfig: webpack.Configuration = {
parallelism: Number(process.env.NEXT_WEBPACK_PARALLELISM) || undefined,
externals: !isServer
? // make sure importing "next" is handled gracefully for client
// bundles in case a user imported types and it wasn't removed
Expand Down
4 changes: 3 additions & 1 deletion packages/next/build/webpack/plugins/profiling-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,11 @@ export class ProfilingPlugin {
return module.userRequest.split('.').pop()
})()

const issuerModule = compilation.moduleGraph.getIssuer(module)

const span = trace(
`build-module${moduleType ? `-${moduleType}` : ''}`,
compilerSpan.id
issuerModule ? spans.get(issuerModule)?.id : compilerSpan.id
)
span.setAttribute('name', module.userRequest)
spans.set(module, span)
Expand Down

0 comments on commit 505640d

Please sign in to comment.