Error Reporting in AWS Lambda

Update:
Lambda shuts down before the default Transport (ThreadedHTTPTransport) can fire off. You may find more success in the synchronous Transport (HTTPTransport).

I’m leveraging the Raven package for Python 2.7 in a small app running in AWS Lambda. I’m running into an issue transporting the events up to Sentry when an exception is encountered.

When the app in Lambda raises an exception, AWS will return the stacktrace and terminate the instance. I believe this is the source of the issue, as the events are still pending HTTP transport.

I’m not an expert in Python, but I believe the package is spooling the messages. According to the Client definition, there are several transports available. According to the transport docs, the HTTPTransport should block report the event during thread execution. This is not occurring for me.

I’ve bootstrapped Raven as a log handler as well as directly invoking captureException to no avail. Any guidance is appreciated.

I’m having the same problem. Did you find the solution @kris?

@jakul

I discovered two things:

  1. When using the raven lib, you don’t pass the exception into captureException(). Maybe you know this, but i’m relatively new to python dev

  2. Lambda shuts down as soon as the main handler exits. By default, the lib uses a threaded spool for the exceptions, so you’ll have to change the default Transport - to HTTPTransport. Here’s what my bootstrapping looks like:

sentry = Client(dsn=Env.sentry_dsn, transport=HTTPTransport)

Thanks, that’s fixed it for us!

1 Like

Check the related Raven issue: https://github.com/getsentry/raven-python/issues/1063