- Newest
- Most votes
- Most comments
hey, Powertools for AWS maintainer here (note: we have on-call for GitHub while repost is monitored by AWS Premium Support).
Without knowing how your code is structured, I suspect you have a large call stack that X-Ray is unable to process (64K trace limit). In practical words, I suspect you are calling other functions inside lambda_handler
, which are also annotated with @tracer.capture_method
.
Example scenario that I can reproduce this:
from aws_lambda_powertools import Tracer tracer = Tracer() @tracer.capture_method(capture_response=False) def process_something(): ... @tracer.capture_lambda_handler(capture_response=False, capture_error=True) def lambda_handler(event: dict, context: LambdaContext) -> str: imaginary_batch = event.get("Records", []) for iteration in imaginary_batch: process_something()
If my theory is correct, comment out the line @tracer.capture_lambda_handler
and it should work. Leave other functions annotated (@tracer.capture_method
) as-is.
Let me know how it goes!
Heitor Lessa
If theory is correct, technical explanation as to why that happens despite using
capture_response=False
.
The entry point is lambda_handler
. Therefore, a X-Ray subsegment named ## lambda_handler
begins the moment the function is invoked. Until that function doesn't complete, it will not complete a X-Ray Trace subsegment. Once it completes, it sends to X-Ray for processing.
However, if you are calling another function (think deeply nested) from your entry point that is also emitting subsegments (## process_something
), then the subsegment ## lambda_handler
never completes.. eventually error out as it reaches the 64K limit in X-Ray.
"Visually" looking like this:
## lambda_handler
## process_something
## process_something
## process_something
## process_something
## process_something
- N more times until..
Message too long
Why
capture_response=False
is ineffective here
This flag would only work if say process_something
function returns a response larger than 64K, for example a large transcript, a S3 file content, etc. That's why it works for most people.
Relevant content
- asked 3 years ago
- asked a year ago
- AWS OFFICIALUpdated 2 years ago