Open IvDoorn opened 4 years ago
Additionally, if I tweak the script to:
import asyncio
import sys
from aws_xray_sdk import global_sdk_config
from aws_xray_sdk.core import xray_recorder
# Enable SDK based on argument
if 'enable' in sys.argv:
print('Enabling XRay')
global_sdk_config.set_sdk_enabled(True)
else:
print('Disbling XRay')
global_sdk_config.set_sdk_enabled(False)
def test_normal():
with xray_recorder.capture('normal'):
print('IN NORMAL')
async def test_async():
with xray_recorder.capture_async('async'):
print('IN ASYNC')
if 'normal' in sys.argv:
print('EXECUTE NORMAL')
test_normal()
if 'async' in sys.argv:
print('EXECUTE ASYNC')
asyncio.get_event_loop().run_until_complete(test_async())
Note that I replaced the: @xray_recorder.capture{_async}
sections with: with xray_recorder.capture{_async}
In this case, all 4 variants of calling the function are failing with the same error. So even for the normal synchronous method the Python doesn't adhere to the fact that the SDK is disabled.
Hi IvDoorn,
Thanks for the detailed bug report. I think it's safe to assume we're missing a disabled check (and a test along with it). We'll dive into this and verify as soon as we can. We are also happy to take PRs from the community.
Thanks, Sandra
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs in next 7 days. Thank you for your contributions.
When disabling the XRay API using global_sdk_config. I'm still getting errors when using the Async pattern.
I've created the following script to demonstrate the bug:
[PASS] Enable XRay, execute sync call
If I call this script:
The output is:
Which is what I would expect. I never created a segment, so it is perfectly correct to raise exception.
[PASS] Disable XRay, execute sync call
When I call the script again:
The output is:
Again correct. (I'm not entirely sure if the "cannot find the current segment/subsegment, please make sure you have a segment open" message is justified, as I've disabled the SDK, I actually am not expecting it to report me anything. But I'll let that one slide for this report.
[PASS] Enable XRay, execute async call
I execute the script:
And output:
Just like the synchronous call. I was expecting this.
[FAIL] Disable XRay, execute async call
I execute the script again:
And now the fun begins:
And it fails.. The XRay SDK is disabled, but still it complains that I have to open the segment. I guess somewhere there is a check missing for the global_sdk_config.is_enabled() state.