Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add aws_lambda_handler decorator to Client #378

Merged
merged 4 commits into from
Apr 4, 2024
Merged

Conversation

imjoehaines
Copy link
Contributor

@imjoehaines imjoehaines commented Apr 3, 2024

Goal

This PR adds a decorator that wraps an AWS Lambda handler that:

  1. reports any errors raised by the handler
  2. creates a session for the function invocation
  3. adds the event and context parameters as metadata, under the names "AWS Lambda Event" and `AWS Lambda Context"
  4. waits for outstanding event and session requests to finish before allowing the lambda to exit (with a timeout of 2 seconds by default)

Usage:

@bugsnag.aws_lambda_handler
def my_handler(event, context):
    pass

The maximum time to wait for events and sessions to be delivered is configurable with the flush_timeout_ms parameter:

@bugsnag.aws_lambda_handler(flush_timeout_ms=1000)
def my_handler(event, context):
    pass

@imjoehaines imjoehaines merged commit 4937d84 into next Apr 4, 2024
20 checks passed
@imjoehaines imjoehaines deleted the add-aws-lambda-handler branch April 4, 2024 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants