aws-xray-sdk-python: SegmentNotFoundException was raised when AWS_XRAY_SDK_ENABLED=false and use/call any method of xray_recorder
Hello, what is the correct way to disable X-Ray SDK without having to remove from my code the calls to the xray_recorder methods?
I’m using in a Django project that runs on Lambda, however, for local development or in Codebuild, I’d like to deactivate it, but if I disable the SDK by configuring the AWS_XRAY_SDK_ENABLED
environment variable to false
I get this error:
aws_xray_sdk.core.exceptions.exceptions.SegmentNotFoundException: cannot find the current segment/subsegment, please make sure you have a segment open
My project use
boto3==1.9.144
botocore==1.12.145
aws-xray-sdk==2.4.2
django==2.1.8
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 3
- Comments: 22 (13 by maintainers)
Commits related to this issue
- Disable SDK Bug fix (#155) Redesign of SDK disabling. Disabling is done at the recorder level. All combination of recorder API calls no longer throw exceptions. Any API call that isn't a passover met... — committed to chanchiem/aws-xray-sdk-python by chanchiem 5 years ago
- Disable SDK Bug fix (#155) Redesign of SDK disabling. Disabling is done at the recorder level. All combination of recorder API calls no longer throw exceptions. Any API call that isn't a passover met... — committed to luzfcb/aws-xray-sdk-python by chanchiem 5 years ago
+1
Meanwhile this is being reviewed, I’ve created the following helper methods in a tracing decorator if that helps anyone:
Hi @mjhanke I’m trying to repro the issue with a sample django app with this configuration. Will get back with an update soon.
In the meantime, can you confirm that when you’re running the app locally or in lambda, the
AWS_XRAY_SDK_ENABLED
is actually set to false andglobal_sdk_config.sdk_enabled()
indeed returns false. If the SDK is disabled successfully, it should hit this line of code and return a DummySubsegment. Can you debug this and confirm as well?Thanks.
I’m not sure how to elaborate other than show you all
aws-xray-sdk-python
related config 😬 let me know if I can be more specific. From our djangoconfig.py
:Hi everyone, this fix was released in the v2.5.0 of the SDK. Hopefully that solves your issue. I’m closing this one. Please feel free to reopen or create a new issue if you’re still having troubles.
Thanks