From ac2ec046dae2256b14d52c557e646b623efd4b81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=A4=80=EA=B7=BC?= <86228307+Jxxunnn@users.noreply.github.com> Date: Mon, 3 Aug 2026 16:54:52 +0900 Subject: [PATCH 1/2] fix(v10/profiling-node): Respect profileSessionSampleRate in trace profile lifecycle Backport of: #22928 --- packages/profiling-node/src/integration.ts | 6 +++++ .../profiling-node/test/integration.test.ts | 22 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/packages/profiling-node/src/integration.ts b/packages/profiling-node/src/integration.ts index 943ae5e35c7b..19644cf985e2 100644 --- a/packages/profiling-node/src/integration.ts +++ b/packages/profiling-node/src/integration.ts @@ -258,6 +258,12 @@ class ContinuousProfiler { * Starts trace lifecycle profiling. Profiling will remain active as long as there is an active span. */ private _startTraceLifecycleProfiling(): void { + if (!this._sampled) { + DEBUG_BUILD && + debug.log('[Profiling] Profile session not sampled, trace lifecycle profiling will not be started.'); + return; + } + if (!this._client) { DEBUG_BUILD && debug.log( diff --git a/packages/profiling-node/test/integration.test.ts b/packages/profiling-node/test/integration.test.ts index 04f8736172d8..fb1ff28414d5 100644 --- a/packages/profiling-node/test/integration.test.ts +++ b/packages/profiling-node/test/integration.test.ts @@ -859,9 +859,28 @@ describe('ProfilingIntegration', () => { expect(stopProfilingSpy).not.toHaveBeenCalled(); }); + it('does not start profiler when profile session is not sampled', () => { + const [client] = makeCurrentSpanProfilingClient({ + profileLifecycle: 'trace', + profileSessionSampleRate: 0, + }); + + Sentry.setCurrentClient(client); + client.init(); + + const startProfilingSpy = vi.spyOn(CpuProfilerBindings, 'startProfiling'); + + const span = Sentry.startInactiveSpan({ forceTransaction: true, name: 'test' }); + + expect(startProfilingSpy).not.toHaveBeenCalled(); + + span.end(); + }); + it('starts profiler when first span is created', () => { const [client] = makeCurrentSpanProfilingClient({ profileLifecycle: 'trace', + profileSessionSampleRate: 1, }); Sentry.setCurrentClient(client); @@ -882,6 +901,7 @@ describe('ProfilingIntegration', () => { it('waits for the tail span to end before stopping the profiler', () => { const [client] = makeCurrentSpanProfilingClient({ profileLifecycle: 'trace', + profileSessionSampleRate: 1, }); Sentry.setCurrentClient(client); @@ -906,6 +926,7 @@ describe('ProfilingIntegration', () => { it('ending last span does not stop the profiler if first span is not ended', () => { const [client] = makeCurrentSpanProfilingClient({ profileLifecycle: 'trace', + profileSessionSampleRate: 1, }); Sentry.setCurrentClient(client); @@ -928,6 +949,7 @@ describe('ProfilingIntegration', () => { it('multiple calls to span.end do not restart the profiler', () => { const [client] = makeCurrentSpanProfilingClient({ profileLifecycle: 'trace', + profileSessionSampleRate: 1, }); Sentry.setCurrentClient(client); From 4c166c05b352ee4f05efa72aeeab75877887dff2 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Mon, 3 Aug 2026 10:22:57 +0200 Subject: [PATCH 2/2] contributor attribution --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ce1af85aff2..c2d78dffe5a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ - "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott +Work in this release was contributed by @Jxxunnn. Thank you for your contribution! + ## 10.69.0 ### Important Changes