How to setup pyrollbar with AWS Lambda
The biggest issue with the Lambda execution environment is that as soon as you return from your handler function, any work executing in other threads will stop executing as the process is frozen. This is true also of any child processes that one may spawn. Furthermore, the Lambda environment implements multithreading via a hypervisor on a single CPU core. Therefore, using separate threads to do additional work will not necessarily lead to better performance.
In order to ensure that the Rollbar library works correctly, meaning that items are transmitted to the Rollbar API, one must not return from the main handler function before all of this work completes. In order to ensure this, one can either use the blocking handler by specifying this value in the configuration,
or use the Rollbar function wait to delay the return from your function until all Rollbar threads have finished. Note that we use threads for the handler if otherwise unspecified, therefore you must use wait if you do not set the handler.
wait is a function which takes an optional function as an argument. It waits for all currently running Rollbar created threads to stop processing, meaning it waits for any items to be sent over the network, then it returns the result of calling the function passed as an argument or None if no function was given. Hence, one can use it via
We provide a decorator for your handler functions which takes care of calling wait properly as well as catching any exceptions, namely rollbar.lambda_function:
Updated over 2 years ago
| Products | Platform | Documentation | Resources | Company | ||
| Product | JavaScript | PHP | Docs Overview | Blog | About Us | |
| Pricing | Ruby | Python | Setting up Rollbar | Guides | Careers | |
| Customers | iOS | Java | Notifications | Contact Us | ||
| Platforms | .NET | Angular | Deploy Tracking | Changelog | ||
| Integrations | React | Laravel | Telemetry | |||
| Node | Rails | Security & Compliance | ||||
| Django | More... | API | ||||
| 2012-25 Rollbar Inc. Privacy Policy Terms of Service | ||||||