@@ -57,7 +57,7 @@ def configure(self, sampling=None, plugins=None,
57
57
context_missing = None , sampling_rules = None ,
58
58
daemon_address = None , service = None ,
59
59
context = None , emitter = None ,
60
- dynamic_naming = None ):
60
+ dynamic_naming = None , streaming_threshold = None ):
61
61
"""Configure global X-Ray recorder.
62
62
63
63
Configure needs to run before patching thrid party libraries
@@ -90,6 +90,9 @@ def configure(self, sampling=None, plugins=None,
90
90
:param dynamic_naming: a string that defines a pattern that host names
91
91
should match. Alternatively you can pass a module which
92
92
overrides ``DefaultDynamicNaming`` module.
93
+ :param streaming_threshold: If breaks within a single segment it will
94
+ start streaming out children subsegments. By default it is the
95
+ maximum number of subsegments within a segment.
93
96
94
97
Environment variables AWS_XRAY_DAEMON_ADDRESS, AWS_XRAY_CONTEXT_MISSING
95
98
and AWS_XRAY_TRACING_NAME respectively overrides arguments
@@ -111,6 +114,8 @@ def configure(self, sampling=None, plugins=None,
111
114
self .context .context_missing = os .getenv (CONTEXT_MISSING_KEY , context_missing )
112
115
if dynamic_naming :
113
116
self .dynamic_naming = dynamic_naming
117
+ if streaming_threshold :
118
+ self .streaming_threshold = streaming_threshold
114
119
115
120
plugin_modules = None
116
121
if plugins :
@@ -259,7 +264,7 @@ def stream_subsegments(self):
259
264
if not segment or not segment .sampled :
260
265
return
261
266
262
- if segment .get_total_subsegments_size () <= self ._max_subsegments :
267
+ if segment .get_total_subsegments_size () <= self .streaming_threshold :
263
268
return
264
269
265
270
# find all subsegments that has no open child subsegments and
@@ -326,6 +331,10 @@ def record_subsegment(self, wrapped, instance, args, kwargs, name,
326
331
stack = traceback .extract_stack (limit = self ._max_trace_back )
327
332
raise
328
333
finally :
334
+ # No-op if subsegment is `None` due to `LOG_ERROR`.
335
+ if subsegment is None :
336
+ return
337
+
329
338
end_time = time .time ()
330
339
if callable (meta_processor ):
331
340
meta_processor (
@@ -440,3 +449,11 @@ def emitter(self):
440
449
@emitter .setter
441
450
def emitter (self , value ):
442
451
self ._emitter = value
452
+
453
+ @property
454
+ def streaming_threshold (self ):
455
+ return self ._max_subsegments
456
+
457
+ @streaming_threshold .setter
458
+ def streaming_threshold (self , value ):
459
+ self ._max_subsegments = value
0 commit comments