I have a very simple Lambda function that I invoke with an IOT Button that runs an ECS Task, very light weight stuff. I had been interested in adding Tracing and found the "One-Click" tracing you get from Lambda does not give you a whole lot out of the box.
I have been reading through some posts about Decorators and the SDK Github as well as the AWS Docs on Python tracing for Lambda and thought it should be easy enough.
The beginning of my function is now as follows
import boto3
from aws_xray_sdk.core import xray_recorder
@xray_recorder.capture("handler")
def handler(event,context):
client = boto3.client('ecs')
response = client.run_task(
---python code---
return str(response)
To which testing now gives me an error like such:
Response:
{
"errorMessage": "Unable to import module 'lambda_function'"
}
Request ID:
"REQID...e3f379f4702a"
Function Logs:
START RequestId: REQID...e3f379f4702a Version: $LATEST
Unable to import module 'lambda_function': No module named 'aws_xray_sdk'
My Handler in the Console is simply lambda_function.handler
, and worked before adding that instrumentation. I have done a few other varieties trying to use Subsegments
instead within the code and run into the same issue. I am pretty novice when it comes to Python, so I am unsure where to check next, or if I am even doing this correctly.
If it's applicable, I had written the code in the console and don't use Layers or ZIP packaging either