diff --git a/Gemfile b/Gemfile index d077ee0..5296365 100644 --- a/Gemfile +++ b/Gemfile @@ -69,6 +69,10 @@ gem 'rack-cors' # Use Redis adapter to run Action Cable in production # gem "redis", ">= 4.0.1" +# Sentry integration according to their documentation [https://docs.sentry.io/platforms/ruby/guides/rails/] +gem "sentry-ruby" +gem "sentry-rails" + gem 'stringex' # Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis] diff --git a/Gemfile.lock b/Gemfile.lock index 411289c..0c3a1bf 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -401,6 +401,12 @@ GEM rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) + 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) simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) @@ -507,6 +513,8 @@ DEPENDENCIES rubocop-rails scout_apm selenium-webdriver + sentry-rails + sentry-ruby simplecov simplecov-lcov sprockets-rails diff --git a/README.md b/README.md index 1a4cc6f..fc4f5f8 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,9 @@ Lots more [Scout settings](https://scoutapm.com/docs/ruby/configuration#environm `SCOUT_LOG_LEVEL`: defaults to INFO which is probably fine. Controls verboseness of Scout logs `SCOUT_NAME`: set a unique name per deployed tier to avoid confusion. +`SENTRY_DSN`: The Sentry-provided key to enable exception logging. Sentry integration is skipped if not present. +`SENTRY_ENV`: Sentry environment for the application. Defaults to 'unknown' if unset. + ### Authentication #### Required in all environments diff --git a/config/initializers/sentry.rb b/config/initializers/sentry.rb new file mode 100644 index 0000000..91ce9ca --- /dev/null +++ b/config/initializers/sentry.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +Sentry.init do |config| + return unless ENV.has_key?('SENTRY_DSN') + config.dsn = ENV.fetch('SENTRY_DSN') + config.breadcrumbs_logger = [:active_support_logger, :http_logger] + config.environment = ENV.fetch('SENTRY_ENV', 'unknown') +end