From 21e2d05d0c7d09eb0804cc73a75d816debfbeebd Mon Sep 17 00:00:00 2001 From: Josh Pigford Date: Mon, 8 Apr 2024 11:29:11 -0500 Subject: [PATCH] Sentry --- .env.example | 4 ++++ Gemfile | 5 +++++ Gemfile.lock | 10 ++++++++++ config/initializers/sentry.rb | 17 +++++++++++++++++ 4 files changed, 36 insertions(+) create mode 100644 config/initializers/sentry.rb diff --git a/.env.example b/.env.example index 3e5719d3..510658e7 100644 --- a/.env.example +++ b/.env.example @@ -21,5 +21,9 @@ POSTGRES_USER=postgres # This is the domain that your Maybe instance will be hosted at. It is used to generate links in emails and other places. APP_DOMAIN= +## Error and Performance Monitoring +# The app uses Sentry to monitor errors and performance. In reality, you likely don't need this unless you're deploying Maybe to many users. +SENTRY_DSN= + # Used to enable specific features unique to the hosted version of Maybe. There's a very high likelihood that you don't need to change this value. HOSTED=false \ No newline at end of file diff --git a/Gemfile b/Gemfile index 6dca1383..39428350 100644 --- a/Gemfile +++ b/Gemfile @@ -29,6 +29,11 @@ gem "good_job" # Search gem "ransack" +# Error logging +gem "stackprof" +gem "sentry-ruby" +gem "sentry-rails" + # Other gem "bcrypt", "~> 3.1.7" gem "inline_svg" diff --git a/Gemfile.lock b/Gemfile.lock index be57a852..e149054d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -347,8 +347,15 @@ GEM rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) + sentry-rails (5.17.2) + railties (>= 5.0) + sentry-ruby (~> 5.17.2) + sentry-ruby (5.17.2) + bigdecimal + concurrent-ruby (~> 1.0, >= 1.0.2) smart_properties (1.17.0) sorbet-runtime (0.5.11332) + stackprof (0.2.26) stimulus-rails (1.3.3) railties (>= 6.0.0) stringio (3.1.0) @@ -430,6 +437,9 @@ DEPENDENCIES rubocop-rails-omakase ruby-lsp-rails selenium-webdriver + sentry-rails + sentry-ruby + stackprof stimulus-rails tailwindcss-rails turbo-rails diff --git a/config/initializers/sentry.rb b/config/initializers/sentry.rb new file mode 100644 index 00000000..56e6b4fc --- /dev/null +++ b/config/initializers/sentry.rb @@ -0,0 +1,17 @@ +if ENV["SENTRY_DSN"].present? + Sentry.init do |config| + config.dsn = ENV["SENTRY_DSN"] + config.breadcrumbs_logger = [ :active_support_logger, :http_logger ] + config.enabled_environments = %w[production] + + # 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 = 1.0 + + # Set profiles_sample_rate to profile 100% + # of sampled transactions. + # We recommend adjusting this value in production. + config.profiles_sample_rate = 1.0 + end +end