File tree 2 files changed +15
-2
lines changed
2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change 21
21
from ddtrace .internal .rate_limiter import BudgetRateLimiterWithJitter as RateLimiter
22
22
from ddtrace .internal .rate_limiter import RateLimitExceeded
23
23
from ddtrace .internal .utils .time import HourGlass
24
+ from ddtrace .settings .exception_replay import config
24
25
25
26
26
27
log = get_logger (__name__ )
@@ -225,15 +226,17 @@ def on_span_exception(
225
226
226
227
seq = count (1 ) # 1-based sequence number
227
228
228
- while chain :
229
+ frames_captured = 0
230
+
231
+ while chain and frames_captured <= config .max_frames :
229
232
exc , _tb = chain .pop () # LIFO: reverse the chain
230
233
231
234
if _tb is None or _tb .tb_frame is None :
232
235
# If we don't have a traceback there isn't much we can do
233
236
continue
234
237
235
238
# DEV: We go from the handler up to the root exception
236
- while _tb :
239
+ while _tb and frames_captured <= config . max_frames :
237
240
frame = _tb .tb_frame
238
241
code = frame .f_code
239
242
seq_nr = next (seq )
@@ -263,6 +266,9 @@ def on_span_exception(
263
266
# Memoize
264
267
frame .f_locals [SNAPSHOT_KEY ] = snapshot_id = snapshot .uuid
265
268
269
+ # Count
270
+ frames_captured += 1
271
+
266
272
# Add correlation tags on the span
267
273
span .set_tag_str (FRAME_SNAPSHOT_ID_TAG % seq_nr , snapshot_id )
268
274
span .set_tag_str (FRAME_FUNCTION_TAG % seq_nr , code .co_name )
Original file line number Diff line number Diff line change @@ -14,6 +14,13 @@ class ExceptionReplayConfig(En):
14
14
help = "Enable automatic capturing of exception debugging information" ,
15
15
deprecations = [("debugging.enabled" , None , "3.0" )],
16
16
)
17
+ max_frames = En .v (
18
+ int ,
19
+ "replay.capture_max_frames" ,
20
+ default = float ("inf" ),
21
+ help_type = "int" ,
22
+ help = "The maximum number of frames to capture for each exception" ,
23
+ )
17
24
18
25
19
26
config = ExceptionReplayConfig ()
You can’t perform that action at this time.
0 commit comments