amazon-web-serviceslambdapython-asynciofastapiaws-xray

Disabling AWS X-ray in FastAPI Lambda application


We have a Lambda application written in FastAPI and we had enabled X-ray for it. However, we decided to move to Datadog and now we don't need X-ray anymore. However, we're finding it hard to actually disable X-ray from recording traces.

These are the approaches we've tried:

  1. global_sdk_config.set_sdk_enabled(False) (Disabling through the SDKConfig module)
  2. AWS_XRAY_SDK_ENABLED=false (Disabling through the environment variable)
  3. Not even calling the functions to start/end segments
  4. Adding another env var according to the source code - AWS_XRAY_SDK_ENABLED - and setting it to false

But none of them worked. We are still getting the traces on the AWS X-ray console.

We also found an open issue with the aws-xray-sdk-python library that says that it's currently may not even be possible to disable X-ray for async. And we use async extensively since we have FastAPI.

We wanted to understand from the community if turning off X-ray is indeed impossible for async flow (because the Github issue is still open). We have even considered reaching out to AWS technical support, but wanted to understand from the StackOverflow community first.


Solution

  • I figured this out.

    Xray tracing is separately configured for API Gateways as well. I had to turn that off, along with tracing for functions, in order to completely remove Xray from our architecture.