I am trying to instrument an AWS Lambda function using X Ray. According to the official documentation of the aws_xray_sdk
, I can't instrument anything outside the handler function. If I have the following sample code:
from aws_xray_sdk.core import xray_recorder
@xray_recorder.capture("handler")
def my_handler(event, context):
# some code here
xray_recorder.begin_subsegment("my_function")
my_function(params)
xray_recorder.end_subsegment("my_function")
return {"message": "done"}
@xray_recorder.capture("my_function")
def my_function(params):
# do work
nothing gets instrumented in X-Ray traces other than handler
. I have tried with different combinations of begin_subsegment
and not having @xray_recorder.capture()
on my_function
. Nothing seems to generate any traces for my_function
. How do I work around this?
Please try to change
to