Hello,
Has anyone successfully implemented AWS Powertools for Python in serverless? I have added the permissions for xray:
- Effect: Allow
Action:
- xray:PutTraceSegments
- xray:PutTelemetryRecords
Resource: "*"
set Tracing to Active:
Tracing: Active
and have set the environment variables:
environment:
POWERTOOLS_SERVICE_NAME: test
POWERTOOLS_LOGGER_LOG_EVENT: True
POWERTOOLS_METRICS_NAMESPACE: test
added imports for the tracer and logger components:
from aws_lambda_powertools import Tracer, Logger
# Setting up aws-powertools tracing and logging
tracer = Tracer()
logger = Logger()
logger.setLevel(LOG_LEVEL)
In the lambda function I added the following to my main function:
@tracer.capture_lambda_handler
def notify(event, context):
logger.debug("event: %s", event)
...
service = event['detail']['service']
logger.debug("service: %s", service)
...
The logging functionality works when I execute the lambda, but I don’t see any traces being generated. Any help with this would be appreciated.