aws / chalice

Python Serverless Microframework for AWS
Apache License 2.0
10.68k stars 1.01k forks source link

Enabling CodeGuru #1593

Open 0xjjoyy opened 4 years ago

0xjjoyy commented 4 years ago

Is there a single point of configuration that we can easily enable the CodeGuru hooks and annotations for our apis?

Python CodeGuru now available. https://aws.amazon.com/about-aws/whats-new/2020/12/python-support-for-amazon-codeguru-is-available-in-preview/

jamesls commented 3 years ago

Hi, there isn't anything specific you'd need to do in terms of Chalice configuration, you'd just need to add the library and decorate your lambda functions as described here (https://docs.aws.amazon.com/codeguru/latest/profiler-ug/python-lambda-command-line.html). We should update our documentation though with a concrete example of how to do this with Chalice apps.

0xjjoyy commented 3 years ago

Thanks, I guess I was hoping there would be a way to apply the decorator to all the api methods, rather than manually adding to all my api methods.

Or are you saying to somehow decorate the app itself? So I can somehow decorate

app = Chalice(app_name='helloworld')

akats commented 3 years ago

This worked for me:

app = app_main.get_app() # this includes a line     chalice_app = Chalice(app_name=xxx)
Profiler(os.getenv("AWS_CODEGURU_PROFILER_GROUP_NAME")).start()

And I had to set up the codeguru group name as a non-lambda compute platform. I would appreciate official clarification if this is the right way forward.