Lightrun for Serverless Functions¶
To run a Serverless function with the Lightrun Python agent, follow these steps:
- Ensure that the Lightrun agent has been configured to work with your serverless function. For example, to use Lightrun with an AWS Lambda function, you must first package the Lightrun agent into an AWS Lambda Layer. Follow the instructions here to setup a lambda layer for your Lightrun Python agent.
- Add the following to your function code.
from lightrun.decorators import lightrun_serverless @lightrun_serverless(company_key = 'aaaaaa-bbbb-cccc-dddd-eeeeeeeeeee', lightrun_tags = ['tag1', 'tag2']) def serverless_func(): """Code"""
- Run your serverless function as normal.
The Lightrun serverless decorator wraps around your serverless function and ensures that the Lightrun agent is enabled before calling the serverless function. It also disables the Lightrun agent when the function call finishes so that it can properly handle the next call to the serverless function.
Last update: May 29, 2023