Skip to content

streaming_threshold not None check. Also dropping loop parameter from aiobotocore tests. #205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 4, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion aws_xray_sdk/core/recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions tests/ext/aiobotocore/test_aiobotocore.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'})
Expand All @@ -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,
Expand Down Expand Up @@ -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})
Expand Down Expand Up @@ -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})
Expand All @@ -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'})
Expand All @@ -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})
Expand Down
10 changes: 10 additions & 0 deletions tests/test_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
16 changes: 10 additions & 6 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@ deps =
py{27}: enum34

# Python3.5+ only deps
py{35,36,37,38}: aiohttp >= 3.0.0
py{35,36,37,38}: aiohttp >= 3.3.1
py{35,36,37,38}: pytest-aiohttp
py{35,36,37,38}: aiobotocore >= 0.10.0
py{35,36,37,38}: botocore >= 1.15.3,<1.15.16
# aiobotocore 0.12.0 is not available for python 3.5
py{35}: aiobotocore >= 0.10.0
# bumping aiobotocore version due to breaking changes to our tests.
py{36,37,38}: aiobotocore >= 0.12.0

commands =
py{27,34}: coverage run --source aws_xray_sdk -m py.test tests --ignore tests/ext/aiohttp --ignore tests/ext/aiobotocore --ignore tests/test_async_local_storage.py --ignore tests/test_async_recorder.py
Expand All @@ -49,7 +53,7 @@ deps =
pytest > 3.0.0
aiohttp >= 2.3.0,<3.0.0
pytest-aiohttp
botocore
botocore >= 1.15.3,<1.15.16
coverage==4.5.4

commands =
Expand All @@ -60,7 +64,7 @@ deps =
pytest > 3.0.0
aiohttp >= 2.3.0,<3.0.0
pytest-aiohttp
botocore
botocore >= 1.15.3,<1.15.16
coverage==4.5.4

commands =
Expand All @@ -71,7 +75,7 @@ deps =
pytest > 3.0.0
aiohttp >= 2.3.0,<3.0.0
pytest-aiohttp
botocore
botocore >= 1.15.3,<1.15.16
coverage==4.5.4

commands =
Expand All @@ -82,7 +86,7 @@ deps =
pytest > 5.2.0
aiohttp >= 3.6
pytest-aiohttp
botocore
botocore >= 1.15.3,<1.15.16
coverage==4.5.4

commands =
Expand Down