From 95e350cb78fa7126990c6b0c3877e8f37855d984 Mon Sep 17 00:00:00 2001 From: Nicolas <> Date: Wed, 6 Nov 2024 16:01:26 +0100 Subject: [PATCH] chore: add Sentry errors monitoring --- Gemfile | 6 ++++++ Gemfile.lock | 8 ++++++++ config/initializers/sentry.rb | 13 +++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 config/initializers/sentry.rb diff --git a/Gemfile b/Gemfile index 2a4c646..191cc9a 100644 --- a/Gemfile +++ b/Gemfile @@ -85,3 +85,9 @@ group :development do # Speed up commands on slow machines / big apps [https://github.com/rails/spring] # gem "spring" end + +group :production do + # Monitoring and error reporting + gem "sentry-rails" + gem "sentry-ruby" +end diff --git a/Gemfile.lock b/Gemfile.lock index 24d126a..62021dc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -333,6 +333,12 @@ GEM rubocop-rspec (~> 3, >= 3.0.1) ruby-progressbar (1.13.0) securerandom (0.3.1) + sentry-rails (5.21.0) + railties (>= 5.0) + sentry-ruby (~> 5.21.0) + sentry-ruby (5.21.0) + bigdecimal + concurrent-ruby (~> 1.0, >= 1.0.2) shellany (0.0.1) sprockets (4.2.1) concurrent-ruby (~> 1.0) @@ -402,6 +408,8 @@ DEPENDENCIES rubocop-rails rubocop-rspec rubocop-rspec_rails + sentry-rails + sentry-ruby sprockets-rails stimulus-rails turbo-rails diff --git a/config/initializers/sentry.rb b/config/initializers/sentry.rb new file mode 100644 index 0000000..aa4e49d --- /dev/null +++ b/config/initializers/sentry.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +if defined?(Sentry) + Sentry.init do |config| + config.dsn = ENV.fetch("SENTRY_DSN") + config.breadcrumbs_logger = %i[active_support_logger http_logger] + + # Set traces_sample_rate to 1.0 to capture 100% + # of transactions for performance monitoring. + # We recommend adjusting this value in production. + config.traces_sample_rate = 0.5 + end +end