diff --git a/aws_xray_sdk/core/recorder.py b/aws_xray_sdk/core/recorder.py index b953cece..cbf5f3d9 100644 --- a/aws_xray_sdk/core/recorder.py +++ b/aws_xray_sdk/core/recorder.py @@ -159,7 +159,7 @@ class to have your own implementation of the streaming process. self.dynamic_naming = dynamic_naming if streaming: self.streaming = streaming - if streaming_threshold: + if streaming_threshold is not None: self.streaming_threshold = streaming_threshold if type(max_trace_back) == int and max_trace_back >= 0: self.max_trace_back = max_trace_back diff --git a/tests/ext/aiobotocore/test_aiobotocore.py b/tests/ext/aiobotocore/test_aiobotocore.py index 6b14ea59..4389c8f2 100644 --- a/tests/ext/aiobotocore/test_aiobotocore.py +++ b/tests/ext/aiobotocore/test_aiobotocore.py @@ -28,7 +28,7 @@ async def test_describe_table(loop, recorder): req_id = '1234' response = {'ResponseMetadata': {'RequestId': req_id, 'HTTPStatusCode': 403}} - session = aiobotocore.get_session(loop=loop) + session = aiobotocore.get_session() async with session.create_client('dynamodb', region_name='eu-west-2') as client: with Stubber(client) as stubber: stubber.add_response('describe_table', response, {'TableName': 'mytable'}) @@ -53,7 +53,7 @@ async def test_s3_parameter_capture(loop, recorder): version_id = 'myversionid' response = {'ResponseMetadata': {'RequestId': '1234', 'HTTPStatusCode': 200}} - session = aiobotocore.get_session(loop=loop) + session = aiobotocore.get_session() async with session.create_client('s3', region_name='eu-west-2') as client: with Stubber(client) as stubber: stubber.add_response('get_object', response, @@ -87,7 +87,7 @@ async def test_list_parameter_counting(loop, recorder): } } - session = aiobotocore.get_session(loop=loop) + session = aiobotocore.get_session() async with session.create_client('sqs', region_name='eu-west-2') as client: with Stubber(client) as stubber: stubber.add_response('list_queues', response, {'QueueNamePrefix': queue_name_prefix}) @@ -117,7 +117,7 @@ async def test_map_parameter_grouping(loop, recorder): } } - session = aiobotocore.get_session(loop=loop) + session = aiobotocore.get_session() async with session.create_client('dynamodb', region_name='eu-west-2') as client: with Stubber(client) as stubber: stubber.add_response('batch_write_item', response, {'RequestItems': ANY}) @@ -137,7 +137,7 @@ async def test_context_missing_not_swallow_return(loop, recorder): response = {'ResponseMetadata': {'RequestId': '1234', 'HTTPStatusCode': 403}} - session = aiobotocore.get_session(loop=loop) + session = aiobotocore.get_session() async with session.create_client('dynamodb', region_name='eu-west-2') as client: with Stubber(client) as stubber: stubber.add_response('describe_table', response, {'TableName': 'mytable'}) @@ -150,7 +150,7 @@ async def test_context_missing_not_suppress_exception(loop, recorder): xray_recorder.configure(service='test', sampling=False, context=AsyncContext(loop=loop), context_missing='LOG_ERROR') - session = aiobotocore.get_session(loop=loop) + session = aiobotocore.get_session() async with session.create_client('dynamodb', region_name='eu-west-2') as client: with Stubber(client) as stubber: stubber.add_client_error('describe_table', expected_params={'TableName': ANY}) diff --git a/tests/test_recorder.py b/tests/test_recorder.py index 9cfe687f..e3030d36 100644 --- a/tests/test_recorder.py +++ b/tests/test_recorder.py @@ -74,6 +74,16 @@ def test_subsegments_streaming(): assert xray_recorder.current_subsegment().name == '9' +def test_subsegment_streaming_set_zero(): + xray_recorder.configure(streaming_threshold=0) + segment = xray_recorder.begin_segment('name') + xray_recorder.begin_subsegment(name='sub') + xray_recorder.end_subsegment() + + assert xray_recorder.streaming.streaming_threshold == 0 + assert segment.get_total_subsegments_size() == 0 + + def test_put_annotation_metadata(): segment = xray_recorder.begin_segment('name') xray_recorder.put_annotation('key1', 'value1')