Repository navigation
Certain xray_recorder operations only work in the LambdaContext - #18
Conversation
| Return True if the X-Ray context is `LambdaContext`, rather than the | ||
| regular `Context` (e.g., when testing lambda functions locally). | ||
| """ | ||
| return type(xray_recorder.context) == LambdaContext |
There was a problem hiding this comment.
Hmm, could this throw if X-Ray is not enabled? The technique I've been using to detect lambda is to look for the 'AWS_LAMBDA_FUNCTION_NAME' environment variable.
There was a problem hiding this comment.
I did consider checking the env var, but I felt that env var is only a proxy for truth. E.g., developers may have functions reading this env var (that's why it's provided by AWS), in this case, they still need to manually inject values to this env var for local testing as well.
BTW, I got this idea from the xray sdk: https://github.com/aws/aws-xray-sdk-python/blob/e9d3746155729a28766f866714ce082eb6612ad3/aws_xray_sdk/ext/flask/middleware.py#L23
Tested locally and in lambda, disabling AWS_XRAY_SDK_ENABLED does not cause issues.
What does this PR do?
Certain xray_recorder operations only work in the
LambdaContext, and it breaks when working in the non-lambda X-RayContext(testing functions locally).Motivation
Fix #17