From 78e250bf330ef0811bff2716c669376114910481 Mon Sep 17 00:00:00 2001 From: JonasBa Date: Tue, 27 Jun 2023 09:39:16 -0400 Subject: [PATCH 1/2] feat: collect timings on profiler stop calls --- packages/browser/src/profiling/cache.ts | 4 ---- packages/browser/src/profiling/hubextensions.ts | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) delete mode 100644 packages/browser/src/profiling/cache.ts diff --git a/packages/browser/src/profiling/cache.ts b/packages/browser/src/profiling/cache.ts deleted file mode 100644 index 34b5da5d12fa..000000000000 --- a/packages/browser/src/profiling/cache.ts +++ /dev/null @@ -1,4 +0,0 @@ -import type { Event } from '@sentry/types'; -import { makeFifoCache } from '@sentry/utils'; - -export const PROFILING_EVENT_CACHE = makeFifoCache(20); diff --git a/packages/browser/src/profiling/hubextensions.ts b/packages/browser/src/profiling/hubextensions.ts index 1c04eeb68362..92b62c636249 100644 --- a/packages/browser/src/profiling/hubextensions.ts +++ b/packages/browser/src/profiling/hubextensions.ts @@ -172,9 +172,13 @@ export function wrapTransactionWithProfiling(transaction: Transaction): Transact return null; } + const stopProfilerSpan = transaction.startChild({ description: 'profiler.stop' }); + return profiler .stop() .then((p: JSSelfProfile): null => { + stopProfilerSpan.finish(); + if (maxDurationTimeoutID) { WINDOW.clearTimeout(maxDurationTimeoutID); maxDurationTimeoutID = undefined; @@ -199,6 +203,7 @@ export function wrapTransactionWithProfiling(transaction: Transaction): Transact return null; }) .catch(error => { + stopProfilerSpan.finish(); if (__DEBUG_BUILD__) { logger.log('[Profiling] error while stopping profiler:', error); } From 7038db938eab265aad54b1592f1696fe422d03b4 Mon Sep 17 00:00:00 2001 From: JonasBa Date: Tue, 27 Jun 2023 09:57:43 -0400 Subject: [PATCH 2/2] feat: add op and comment --- packages/browser/src/profiling/hubextensions.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/browser/src/profiling/hubextensions.ts b/packages/browser/src/profiling/hubextensions.ts index 92b62c636249..49763ac35659 100644 --- a/packages/browser/src/profiling/hubextensions.ts +++ b/packages/browser/src/profiling/hubextensions.ts @@ -172,7 +172,9 @@ export function wrapTransactionWithProfiling(transaction: Transaction): Transact return null; } - const stopProfilerSpan = transaction.startChild({ description: 'profiler.stop' }); + // This is temporary - we will use the collected span data to evaluate + // if deferring txn.finish until profiler resolves is a viable approach. + const stopProfilerSpan = transaction.startChild({ description: 'profiler.stop', op: 'profiler' }); return profiler .stop()