robhowley / lambda-warmer-py Goto Github PK
View Code? Open in Web Editor NEWkeep lambdas warm and monitor cold starts with a simple decorator
License: MIT License
keep lambdas warm and monitor cold starts with a simple decorator
License: MIT License
I got such error on lambda warming and I created cloudwatch event rule as you give in example.
[ERROR] KeyError: 'requestContext'
Traceback (most recent call last):
File "/opt/python/lib/python3.8/site-packages/codeguru_profiler_agent/aws_lambda/profiler_decorator.py", line 52, in profiler_decorate
return function(event, context)
File "/opt/python/lib/python3.8/site-packages/codeguru_profiler_agent/aws_lambda/lambda_handler.py", line 91, in call_handler
return handler_function(event, context)
File "/var/task/mangum/adapter.py", line 101, in __call__
scope = self.create_scope(event, context)
File "/var/task/mangum/adapter.py", line 118, in create_scope
request_context = event["requestContext"]
I read README, applied warmer to my lambda.
It seems that json format
{
"warmer": true,
"concurrency": 1
}
written here does not fit what aws requires...
How can I apply event pattern then?
Also, just wondering the reason for using lambda-warmer, not just ping lambda every constant minute using aws cloud watch event bridge.
Maybe I'm off-base here, but it seems like we want to decorate the function so we don't have to think about handling the warming event in any way at all in our code. As it's written, I still have to write custom handling logic for when the warming event comes in. If this change doesn't make sense could you either correct me in my usage or explain to me why it makes sense not to short-circuit inside the decorator?
When the warmer cannot invoke the lambda function (concurrency > 1) there's no way to actually see why.
Printing the exception would be a first help.
lambda-warmer-py/lambdawarmer/__init__.py
Lines 107 to 110 in 1fe7e29
With reference to the code
https://stackoverflow.com/a/39457165/1117238
If the lambda is invoke one by one in a python for loop, wouldn't it just invoke the same lambda instance?
I am using lambda warmers on lambda functions that are connected as resolvers to AWS AppSync (graphql)
AppSync has a feature that enables batches for a lambda function (resolver), resulting in a List of events.
Therefore we receive this error when the invocation is not a warmer invocation.
@functools.wraps(f)
def wrapped_func(event, context, *args, **kwargs):
execution_info = dict(
instance_id=context.aws_request_id,
is_warmer_invocation=event.get(flag) or False,
**LAMBDA_INFO
)
AttributeError: 'list' object has no attribute 'get'
../../../.venv/lib/python3.9/site-packages/lambdawarmer/init.py:34: AttributeError
Hello,
I'm using framework fastApi with mangum for my lambda functions.
Therefore, here is my code to make my app serverless:
from fastapi import FastAPI
from mangum import Mangum
import lambdawarmer
app = FastAPI()
@lambdawarmer.warmer
handler = Mangum(app)
This works perfectly without the @lambdawarmer.warmer line
BUT, this doesn't work as handler should be a function as per your guide.
How should I manage such case ?
Thanks
Does AWS Provisioned Concurrency makes this library obsolete and not needed ? https://docs.aws.amazon.com/lambda/latest/dg/provisioned-concurrency.html
I'm haing an issue when trying to log metrics to cloudwatch, I'm not seeing anything, I'm sending this json as payload:
{ "warmer": true, "concurrency": 6, "send_metric" : true }
also the decorator is on the function
Any suggestion?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.