Code Monkey home page Code Monkey logo

lambda-warmer-py's People

Contributors

alvarhhm avatar mihal277 avatar mvanbaak avatar robhowley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

lambda-warmer-py's Issues

Request Context not found

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"]

cloud watch rule format

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.

The warmer decorator should short-circuit

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?

No info on why lambda invokation fails

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.

Shouldn't the lambda be invoked asynchronizely?

lambda_client.invoke(
FunctionName=LAMBDA_INFO['function_name'],
InvocationType='Event' if i < concurrency - 1 else 'RequestResponse',
Payload=json.dumps(dict(base_payload, __WARMER_INVOCATION__=(i + 1)))

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?

Error on lambdas that get List of events

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

handler not a function

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

event.json is not passed?

Ref screenshots,

I passed the event.json with the required parameters,

But he doesn't seem to find these parameters within the wrapper function.

Screen Shot 2019-04-28 at 11 10 41 AM
Screen Shot 2019-04-28 at 11 05 14 AM

Not Logging metrics to cloudwatch

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.