From ffc736cd0d94e62d07f8b3f7c6809acc3471ee9b Mon Sep 17 00:00:00 2001 From: Attila Szegedi Date: Mon, 14 Oct 2024 17:39:21 +0200 Subject: [PATCH] Defer profile creation until encoding phase --- packages/dd-trace/src/profiling/profilers/events.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/dd-trace/src/profiling/profilers/events.js b/packages/dd-trace/src/profiling/profilers/events.js index e1d42484f13..f8f43b06a9a 100644 --- a/packages/dd-trace/src/profiling/profilers/events.js +++ b/packages/dd-trace/src/profiling/profilers/events.js @@ -330,13 +330,13 @@ class EventsProfiler { if (!restart) { this.stop() } - const profile = this.eventSerializer.createProfile(startDate, endDate) + const thatEventSerializer = this.eventSerializer this.eventSerializer = new EventSerializer() - return profile + return () => thatEventSerializer.createProfile(startDate, endDate) } encode (profile) { - return pprof.encode(profile) + return pprof.encode(profile()) } }