Skip to content

Commit

Permalink
Replace sentry-raven with sentry-rails
Browse files Browse the repository at this point in the history
  • Loading branch information
bensheldon committed Jul 30, 2024
1 parent b6197c8 commit 8ff6832
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ gem 'rack-host-redirect'
gem 'rails', '~> 7.1'
gem 'sass-rails'
gem 'scenic'
gem 'sentry-raven'
gem 'sentry-rails'
gem 'slim'
gem 'slim-rails'
gem 'terser'
Expand Down
10 changes: 7 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,12 @@ GEM
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
websocket (~> 1.0)
sentry-raven (2.13.0)
faraday (>= 0.7.6, < 1.0)
sentry-rails (5.18.2)
railties (>= 5.0)
sentry-ruby (~> 5.18.2)
sentry-ruby (5.18.2)
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
slim (5.2.1)
temple (~> 0.10.0)
tilt (>= 2.1.0)
Expand Down Expand Up @@ -549,7 +553,7 @@ DEPENDENCIES
sass-rails
scenic
selenium-webdriver
sentry-raven
sentry-rails
slim
slim-rails
slim_lint
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/fetch_service_list_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class FetchServiceListJob < ApplicationJob
def perform(city)
Raven.extra_context(city: city.slug)
Sentry.set_context(:city, { slug: city.slug })
Rails.logger.info "Collecting service definitions list from #{city.name}"
api = City::Api.new city
new_service_list = api.fetch_service_list
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/fetch_service_requests_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class FetchServiceRequestsJob < ApplicationJob
def perform(city)
Raven.extra_context(city: city.slug)
Sentry.set_context(:city, { slug: city.slug })
Rails.logger.info "Collecting service requests from #{city.name}"
api = City::Api.new city
new_service_requests = api.fetch_service_requests
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/fetch_service_requests_recursively_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def perform(city, start_at = 7.days.ago, end_at = Time.current, interval = INITI
interval = interval.positive? ? interval.second : 1.second
api_limit = city.requests_limit || 50

Raven.extra_context(city: city.slug)
Sentry.set_context(:city, { slug: city.slug })

start_date = start_at.to_datetime
end_date = end_at.to_datetime
Expand Down
23 changes: 17 additions & 6 deletions config/initializers/sentry.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
Raven.configure do |config|
config.environments = %w[ production ]
end
# frozen_string_literal: true

if defined? Sentry
Sentry.init do |config|
config.enabled_environments = %w[production staging]
config.excluded_exceptions = Sentry::Configuration::IGNORE_DEFAULT + Sentry::Rails::IGNORE_DEFAULT + %w[
ActionController::UnknownFormat
Rack::Timeout::RequestTimeoutError
Rack::Timeout::RequestExpiryError
]

Raven.tags_context({
'environment' => Rails.env
})
# use Rails' parameter filter to sanitize the event
filter = ActiveSupport::ParameterFilter.new(Rails.application.config.filter_parameters - [:name, :filename])
config.before_send = lambda do |event, _hint|
filter.filter(event.to_hash)
end
end
end

0 comments on commit 8ff6832

Please sign in to comment.