From 137680879c2cac09cbbeaa4b31212d9af053c3ad Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Tue, 21 Nov 2023 11:41:58 +0100 Subject: [PATCH 1/4] Add sentry sidekiq --- Gemfile | 1 + Gemfile.lock | 4 ++++ app/jobs/sidekiq_again_job.rb | 1 + 3 files changed, 6 insertions(+) diff --git a/Gemfile b/Gemfile index e4d859b0f..b53c139bd 100644 --- a/Gemfile +++ b/Gemfile @@ -84,6 +84,7 @@ gem 'sassc-rails' # Use SCSS for stylesheets gem 'sentry-delayed_job' gem 'sentry-rails' gem 'sentry-ruby' +gem 'sentry-sidekiq' gem 'sib-api-v3-sdk' gem 'sidekiq' gem 'skylight' diff --git a/Gemfile.lock b/Gemfile.lock index a85c7926b..02600f164 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -682,6 +682,9 @@ GEM sentry-ruby (~> 5.9.0) sentry-ruby (5.9.0) concurrent-ruby (~> 1.0, >= 1.0.2) + sentry-sidekiq (5.9.0) + sentry-ruby (~> 5.9.0) + sidekiq (>= 3.0) shoulda-matchers (4.5.1) activesupport (>= 4.2.0) sib-api-v3-sdk (7.4.0) @@ -921,6 +924,7 @@ DEPENDENCIES sentry-delayed_job sentry-rails sentry-ruby + sentry-sidekiq shoulda-matchers sib-api-v3-sdk sidekiq diff --git a/app/jobs/sidekiq_again_job.rb b/app/jobs/sidekiq_again_job.rb index 1f5b5085e..60b74f3cf 100644 --- a/app/jobs/sidekiq_again_job.rb +++ b/app/jobs/sidekiq_again_job.rb @@ -3,6 +3,7 @@ class SidekiqAgainJob < ApplicationJob queue_as :default def perform(user) + Sentry.capture_message('this is a message from sidekiq') UserMailer.new_account_warning(user).deliver_now end end From 9f6cff07e447e6eb1c9521cea7914621bd52cd29 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Tue, 21 Nov 2023 12:02:58 +0100 Subject: [PATCH 2/4] add active job to skylight probes --- config/application.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/application.rb b/config/application.rb index 151e2b29c..458579197 100644 --- a/config/application.rb +++ b/config/application.rb @@ -80,7 +80,7 @@ module TPS config.ds_zonage_enabled = ENV.fetch("ZONAGE_ENABLED", nil) == "enabled" - config.skylight.probes += [:graphql] + config.skylight.probes += [:graphql, :active_job] # Custom Configuration # @see https://guides.rubyonrails.org/configuring.html#custom-configuration From 1880a15d6952d239639cec55314f316dc441149b Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Wed, 22 Nov 2023 09:56:05 +0100 Subject: [PATCH 3/4] sidekiq test job can raise an exception --- app/jobs/sidekiq_again_job.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/jobs/sidekiq_again_job.rb b/app/jobs/sidekiq_again_job.rb index 60b74f3cf..d819ed936 100644 --- a/app/jobs/sidekiq_again_job.rb +++ b/app/jobs/sidekiq_again_job.rb @@ -2,7 +2,10 @@ class SidekiqAgainJob < ApplicationJob self.queue_adapter = :sidekiq queue_as :default - def perform(user) + def perform(user, with_exception: false) + if with_exception + raise 'Nop' + end Sentry.capture_message('this is a message from sidekiq') UserMailer.new_account_warning(user).deliver_now end From 2e8e401818cfd11509d88f8f9344e09d03764c91 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Wed, 22 Nov 2023 10:08:08 +0100 Subject: [PATCH 4/4] try to update ruby-sentry update dep instead To avoid a deprecation warning from sidekiq relative to exception handling, we need https://github.com/getsentry/sentry-ruby/pull/2160 not yet released --- Gemfile.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 02600f164..0bd3fe815 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -397,7 +397,7 @@ GEM railties (>= 4) request_store (~> 1.0) logstash-event (1.2.02) - loofah (2.21.4) + loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) mail (2.8.1) @@ -444,7 +444,7 @@ GEM net-protocol netrc (0.11.0) nio4r (2.5.9) - nokogiri (1.15.4) + nokogiri (1.15.5) mini_portile2 (~> 2.8.2) racc (~> 1.4) open4 (1.3.4) @@ -497,7 +497,7 @@ GEM pundit (2.2.0) activesupport (>= 3.0.0) raabro (1.4.0) - racc (1.7.1) + racc (1.7.3) rack (2.2.8) rack-attack (6.5.0) rack (>= 1.0, < 3) @@ -559,7 +559,7 @@ GEM thor (~> 1.0) zeitwerk (~> 2.5) rainbow (3.1.1) - rake (13.0.6) + rake (13.1.0) rake-progressbar (0.0.5) rb-fsevent (0.11.2) rb-inotify (0.10.1)