Add Sentry integration to puma.rb
I did a deep dive on why Sentry wasn't able to capture the exception that we identified in gitlab-org/gitlab#336609 (comment 632813416) during the production incident in gitlab-com/gl-infra/production#5194 (closed). Full explanation in: https://github.com/getsentry/sentry-ruby/issues/1511
The bottom line is that Puma has a low-level handler in https://github.com/puma/puma#error-handling that we can connect to Sentry. That way we don't end up only seeing exceptions in the Puma stderr log.
Since the Sentry configuration is also in the gitlab.yml, we ought to be able to configure this automatically inside puma.rb:
lowlevel_error_handler do |ex, env, status|
Raven.capture_exception(
ex,
message: ex.message,
program: 'puma'
)
# note the below is just a Rack response
[500, {}, ["An error has occurred."]]
end