3
3
4
4
from aws_xray_sdk .core import xray_recorder
5
5
from aws_xray_sdk .core .async_context import AsyncContext
6
+ from aws_xray_sdk .core .context import MISSING_SEGMENT_MSG
6
7
from aws_xray_sdk .core .exceptions .exceptions import SegmentNotFoundException
7
8
from aws_xray_sdk .ext .util import strip_url , get_hostname
8
9
from aws_xray_sdk .ext .aiohttp .client import aws_xray_trace_config
@@ -144,7 +145,7 @@ async def test_no_segment_raise(loop, recorder):
144
145
pass
145
146
146
147
147
- async def test_no_segment_not_raise (loop , recorder ):
148
+ async def test_no_segment_log_error (loop , recorder , capsys ):
148
149
xray_recorder .configure (context_missing = 'LOG_ERROR' )
149
150
trace_config = aws_xray_trace_config ()
150
151
status_code = 200
@@ -155,3 +156,20 @@ async def test_no_segment_not_raise(loop, recorder):
155
156
156
157
# Just check that the request was done correctly
157
158
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