Skip to content

Commit

Permalink
Merge pull request #146 from MITLibraries/tco-88
Browse files Browse the repository at this point in the history
Add and configure Sentry gem
  • Loading branch information
matt-bernhardt authored Nov 25, 2024
2 parents 74bd38b + fdd34d5 commit 8b1e2d4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
8 changes: 8 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -507,6 +513,8 @@ DEPENDENCIES
rubocop-rails
scout_apm
selenium-webdriver
sentry-rails
sentry-ruby
simplecov
simplecov-lcov
sprockets-rails
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions config/initializers/sentry.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 8b1e2d4

Please sign in to comment.