This plan's goal is to propose a general guideline on how to handle exceptions that occur when the SDK is sending events to Sentry.
The goal is to make sure:
Related Issues
before_send
callback #1289Below are the types of exceptions that could occur when sending an event to Sentry:
External ExceptionsAn external exception is an error triggered by something outside of the SDK's control. For example:
These exceptions shouldn't interrupt the user's program. For example, failing to send a transaction to Sentry can't cause the response to return 500. This means:
Because the SDK also invokes user-defined callbacks, like before_send
, those callbacks could trigger arbitrary errors. For example:
These exceptions should not be swallowed.
Exception Handling PrinciplesSentry.capture_*
is called shouldn't crash the user's app.Client#capture_event
<- should rescue and log all the errors
async
block - could be either user or external exceptionClient#send_event
before_send
callback - user exceptionHTTPTransport#send_data
- external exceptionAs you can see, the flow can trigger either user or external exceptions, which makes handling them a bit tricky.
Exception Handling In Different ScenariosNow, because Ruby SDK has different sync/async options, the situation gets even more complicated. Here's the breakdown for different scenarios:
Sending Events Inline (without async nor background worker)Client#capture_event
<- should rescue and log all the errors
Client#send_event
before_send
callback - user exceptionHTTPTransport#send_data
- external exceptionThese happen inline
Client#capture_event
<- should rescue and log all the errors
async
block - could be either user or external exceptionThese happen in the worker
Client#send_event
<- should raise both external and user exception
before_send
callback - user exceptionHTTPTransport#send_data
- external exceptionThese happen inline
Client#capture_event
These happen in the worker
Client#send_event
<- should raise both external and user exception
before_send
callback - user exceptionHTTPTransport#send_data
- external exceptionRetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4