From 0d4e4e90924a14ce3e24e8eed88dbd9a4b2bb2fc Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Thu, 23 Sep 2021 00:30:51 +0200 Subject: [PATCH] Fix add-entry span duration (#29288) Currently the span is finished on seal but that's not the actual timing where the entry span is finished as there's a `succeedEntry` hook. This PR changes the span to finish on `succeedEntry`. ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes --- .../build/webpack/plugins/profiling-plugin.ts | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/next/build/webpack/plugins/profiling-plugin.ts b/packages/next/build/webpack/plugins/profiling-plugin.ts index 0b5eba87e0..dbe8406ff6 100644 --- a/packages/next/build/webpack/plugins/profiling-plugin.ts +++ b/packages/next/build/webpack/plugins/profiling-plugin.ts @@ -179,19 +179,19 @@ export class ProfilingPlugin { { parentSpan: () => spans.get(compilation)! } ) - this.traceHookPair( - 'add-entry', - compilation.hooks.addEntry, - compilation.hooks.afterSeal, - { - attrs: (entry: any) => { - return { - request: entry.request, - } - }, - parentSpan: () => spans.get(compilation)!, + compilation.hooks.addEntry.tap(pluginName, (entry: any) => { + const compilationSpan = spans.get(compilation) + if (!compilationSpan) { + return } - ) + const addEntrySpan = compilationSpan.traceChild('add-entry') + addEntrySpan.setAttribute('request', entry.request) + spans.set(entry, addEntrySpan) + }) + + compilation.hooks.succeedEntry.tap(pluginName, (entry: any) => { + spans.get(entry)?.stop() + }) } this.traceHookPair(