Skip to content

Commit 083e78b

Browse files
committed
chore(profiling): Change continuous profile sampling frequency and buffer size
This lowers the sampling frequency of continous profiles to 21Hz and increases the buffer size to 1 minute.
1 parent 48d6368 commit 083e78b

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

sentry_sdk/profiler/continuous_profiler.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@
99
from sentry_sdk.consts import VERSION
1010
from sentry_sdk.envelope import Envelope
1111
from sentry_sdk._lru_cache import LRUCache
12-
from sentry_sdk.profiler.utils import (
13-
DEFAULT_SAMPLING_FREQUENCY,
14-
extract_stack,
15-
)
12+
from sentry_sdk.profiler.utils import extract_stack
1613
from sentry_sdk.utils import (
1714
capture_internal_exception,
1815
is_gevent,
@@ -52,6 +49,11 @@
5249
)
5350

5451

52+
# The default sampling frequency to use. This is set at 21 in order to
53+
# mitigate the effects of lockstep sampling.
54+
DEFAULT_SAMPLING_FREQUENCY = 21
55+
56+
5557
try:
5658
from gevent.monkey import get_original
5759
from gevent.threadpool import ThreadPool as _ThreadPool
@@ -407,7 +409,7 @@ def teardown(self):
407409
self.buffer = None
408410

409411

410-
PROFILE_BUFFER_SECONDS = 10
412+
PROFILE_BUFFER_SECONDS = 60
411413

412414

413415
class ProfileBuffer:

tests/profiler/test_continuous_profiler.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def test_continuous_profiler_auto_start_and_manual_stop(
200200

201201
with sentry_sdk.start_transaction(name="profiling"):
202202
with sentry_sdk.start_span(op="op"):
203-
time.sleep(0.05)
203+
time.sleep(0.1)
204204

205205
assert_single_transaction_with_profile_chunks(envelopes, thread)
206206

@@ -211,7 +211,7 @@ def test_continuous_profiler_auto_start_and_manual_stop(
211211

212212
with sentry_sdk.start_transaction(name="profiling"):
213213
with sentry_sdk.start_span(op="op"):
214-
time.sleep(0.05)
214+
time.sleep(0.1)
215215

216216
assert_single_transaction_without_profile_chunks(envelopes)
217217

@@ -221,7 +221,7 @@ def test_continuous_profiler_auto_start_and_manual_stop(
221221

222222
with sentry_sdk.start_transaction(name="profiling"):
223223
with sentry_sdk.start_span(op="op"):
224-
time.sleep(0.05)
224+
time.sleep(0.1)
225225

226226
assert_single_transaction_with_profile_chunks(envelopes, thread)
227227

0 commit comments

Comments
 (0)