Skip to content

Commit

Permalink
Replace sentry-raven with sentry-ruby
Browse files Browse the repository at this point in the history
No need to capture exceptions manually in the low-level error handler
since getsentry/sentry-ruby#2026

Close #242
  • Loading branch information
dentarg committed Jul 10, 2023
1 parent c096042 commit 6c8b3ce
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ gem 'commonmarker'
gem 'rest-client'
gem 'octokit'
gem 'addressable'
gem 'sentry-raven'
gem 'sentry-ruby'
gem 'racksh'
gem 'warning'
gem 'rake'
Expand Down
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ GEM
sawyer (0.8.2)
addressable (>= 2.3.5)
faraday (> 0.8, < 2.0)
sentry-raven (2.9.0)
faraday (>= 0.7.6, < 1.0)
sentry-ruby (5.10.0)
concurrent-ruby (~> 1.0, >= 1.0.2)
sequel (5.70.0)
sequel_pg (1.17.1)
pg (>= 0.18.0, != 1.2.0)
Expand Down Expand Up @@ -162,7 +162,7 @@ DEPENDENCIES
rake
rest-client
rubocop (~> 1.54.1)
sentry-raven
sentry-ruby
sequel
sequel_pg
sinatra
Expand Down
4 changes: 2 additions & 2 deletions config.ru
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

require_relative 'config/sentry'

require 'rack/ssl-enforcer'
use Sentry::Rack::CaptureExceptions

use Raven::Rack
require 'rack/ssl-enforcer'

# Connects to the database
require_relative 'config/app'
Expand Down
10 changes: 4 additions & 6 deletions config/puma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@
end

lowlevel_error_handler do |ex, env|
Raven.capture_exception(
ex,
:message => ex.message,
:extra => { :puma => env },
:transaction => "Puma"
)
if App.test_lowlevel_error_handler?
puts "puma lowlevel_error_handler ran with exception=#{ex.inspect}"
end

[500, {}, ["An error has occurred, and engineers have been informed.\n"]]
end

Expand Down
13 changes: 9 additions & 4 deletions config/sentry.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
# frozen_string_literal: true

require "raven"
require "sentry-ruby"
require "logger"

require_relative "../lib/app"

Raven.configure do |config|
Sentry.init do |config|
config.logger = App.null_logger if App.test?
config.logger.level = Logger::DEBUG
config.processors -= [Raven::Processor::PostData] # send POST data
config.processors -= [Raven::Processor::Cookies] # send cookies

# https://docs.sentry.io/platforms/ruby/configuration/releases/#release-health
config.auto_session_tracking = false

# send POST data send cookies
# https://docs.sentry.io/platforms/ruby/migration/#removed-processors
config.send_default_pii = true
end
4 changes: 2 additions & 2 deletions test/integration/app_boot_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def test_app_lowlevel_error_handler

get_http_response(port: port)

assert spawn.wait("DEBUG -- sentry: ** [Raven]")
assert spawn.wait("excluded from capture: DSN not set")
assert spawn.wait("DEBUG -- sentry: ** [Sentry] Initializing the background worker")
assert spawn.wait("puma lowlevel_error_handler ran")
end
end

Expand Down
Binary file removed vendor/cache/sentry-raven-2.9.0.gem
Binary file not shown.
Binary file added vendor/cache/sentry-ruby-5.10.0.gem
Binary file not shown.

0 comments on commit 6c8b3ce

Please sign in to comment.