aws-samples / aws-lambda-extensions

A collection of sample extensions to help you get started with AWS Lambda Extensions
MIT No Attribution
445 stars 146 forks source link

python-example-logs-api-extension missing logs for first invoke after a cold start #55

Closed anishamalynur closed 2 years ago

anishamalynur commented 3 years ago

I noticed that logs for the first Lambda's invoke are missing after a cold start but the extension picks up subsequent logs from additional invokes. I was only able to get the first invoke logs if I added an additional delay of 5 seconds here: https://github.com/aws-samples/aws-lambda-extensions/blob/main/python-example-logs-api-extension/extensions/logs_api_http_extension.py#L56 or if I enabled provisioned concurrency. Is there another work around to get the first invokes logs?

julianwood commented 2 years ago

You should be able to wait for the platform.runtimeDone message from Lambda, as mentioned in https://aws.amazon.com/blogs/compute/performance-and-functionality-improvements-for-aws-lambda-extensions/

j-adamczyk commented 2 years ago

@julianwood how would I do that? Should I filter platform.runtimeDone type in batch = self.queue.get_nowait()? Or should this be somewhere in configuration?