appsignal-ruby: Handled sinatra errors being reported to Appsignal

In Sinatra, env['sinatra.error'] is set when an error is encountered. However, this is never unset by Sinatra. The result is that all errors are sent to appsignal, including the handled ones.

This is difficult to work around, as unsetting env['sinatra.error'] causes some error handlers (example: not_found to be run twice. (Sinatra does not expect you to unset this variable).

IMO, the fix is to remove this line from the Appsignal agent, and recommend users put enable :raise_errors in their Sinatra app. This will ensure that unhandled exceptions are raised, and subsequently caught, by the Appsignal agent.

There’s no way (as far as I know) to figure out whether raise_errors is on for any particular app. So something like this wouldn’t work: transaction.set_error(env['sinatra.error']) if env['sinatra.error'] && !raise_errors

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 15 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Thanks for the report @derekkraan! I’m doing some research on this later this week and will get back to you.