Search code examples
amazon-web-servicesaws-lambdaaws-xray

How to enable x-ray tracing for all methods being invoked in the API


I need to debug which method is consuming more time in the lambda invocation, but to enable tracing for any method, we need add @xray_recorder.capture decorator like below.

from aws_xray_sdk.core import xray_recorder

@xray_recorder.capture("my_method")
def my_method():
    pass

How can we dynamically add or any other method to enable tracing for all the methods ?


Solution

  • You can use the middleware provided by xray_sdk to do this, you can also configure which modules to monitor, and which to ignore using the XRAY_RECORDER setting.

    For more info go through the xray_sdk_middleware docs in GitHub.