Skip to content

Commit 57dbc36

Browse files
committed
Added test for segment ignore
1 parent 59711be commit 57dbc36

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

docs/configurations.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ Supported strategies are:
9292

9393
* RUNTIME_ERROR: throw an SegmentNotFoundException
9494
* LOG_ERROR: log an error and continue
95-
* IGNORE: will do nothing
95+
* IGNORE: do nothing
9696

9797
Segment Dynamic Naming
9898
----------------------

tests/ext/aiohttp/test_client.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from aws_xray_sdk.core import xray_recorder
55
from aws_xray_sdk.core.async_context import AsyncContext
6+
from aws_xray_sdk.core.context import MISSING_SEGMENT_MSG
67
from aws_xray_sdk.core.exceptions.exceptions import SegmentNotFoundException
78
from aws_xray_sdk.ext.util import strip_url, get_hostname
89
from aws_xray_sdk.ext.aiohttp.client import aws_xray_trace_config
@@ -144,7 +145,7 @@ async def test_no_segment_raise(loop, recorder):
144145
pass
145146

146147

147-
async def test_no_segment_not_raise(loop, recorder):
148+
async def test_no_segment_log_error(loop, recorder, capsys):
148149
xray_recorder.configure(context_missing='LOG_ERROR')
149150
trace_config = aws_xray_trace_config()
150151
status_code = 200
@@ -155,3 +156,20 @@ async def test_no_segment_not_raise(loop, recorder):
155156

156157
# Just check that the request was done correctly
157158
assert status_received == status_code
159+
captured = capsys.readouterr()
160+
assert MISSING_SEGMENT_MSG in captured.out
161+
162+
163+
async def test_no_segment_ignore(loop, recorder, capsys):
164+
xray_recorder.configure(context_missing='IGNORE')
165+
trace_config = aws_xray_trace_config()
166+
status_code = 200
167+
url = 'http://{}/status/{}?foo=bar'.format(BASE_URL, status_code)
168+
async with ClientSession(loop=loop, trace_configs=[trace_config]) as session:
169+
async with session.get(url) as resp:
170+
status_received = resp.status
171+
172+
# Just check that the request was done correctly
173+
assert status_received == status_code
174+
captured = capsys.readouterr()
175+
assert MISSING_SEGMENT_MSG not in captured.out

0 commit comments

Comments
 (0)