Diego
Diego

Reputation: 36176

aws-xray-sdk on a lambda function

I see that I can enable x-ray tracing on my lambda function just by checking a checkbox (or setting Tracing: Active if using SAM). That adds a high level logging.

If I want more detailed logging, my understanding is that I need to add:

from aws_xray_sdk.core import xray_recorder
from aws_xray_sdk.core import patch_all
patch_all()

however, the xry sdk is not part of lambda. Clearly one of the solutions is to install it with pip install aws-xray-sdk -t . but that will add 42Mb to the function's code.

Is there an alternative solution? thanks

Upvotes: 4

Views: 2350

Answers (2)

haotian465
haotian465

Reputation: 679

You can use lambda layers to bake the X-Ray SDK to your runtime to keep your function code small. See more details on lambda layers https://docs.aws.amazon.com/lambda/latest/dg/configuration-layers.html. Please let me know if you have extra concerns on using layers.

Upvotes: 1

Unfortunately the X-Ray Python SDK is written as a single package, and there are no current work arounds to reduce the payload size.

Upvotes: 1

Related Questions