Skip to content

Commit e0c977d

Browse files
committed
Add Sentry for exception monitoring
Why these changes are being introduced: We want to prepare for TIMDEX-UI as a potential production application. Relevant ticket(s): https://mitlibraries.atlassian.net/browse/TIMX-81 How this addresses that need: This adds sentry-ruby and sentry-rails, including the required initializer. Side effects of this change: * Configures Sentry environment. We haven't done this yet in our Rails apps, but it seems like it will be especially useful for TIMDEX and TIMDEX-UI, for which we have a lot of different environments. * Added SENTRY_ENV and SENTRY_DSN to Heroku config vars.
1 parent 8555711 commit e0c977d

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ gem 'jbuilder'
1111
gem 'mitlibraries-theme', '~> 0.7.0'
1212
gem 'puma', '~> 5.0'
1313
gem 'rails', '~> 7.0.2', '>= 7.0.2.3'
14+
gem 'sentry-rails'
15+
gem 'sentry-ruby'
1416
gem 'sprockets-rails'
1517
gem 'stimulus-rails'
1618
gem 'turbo-rails'

Gemfile.lock

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,11 @@ GEM
247247
rexml (~> 3.2, >= 3.2.5)
248248
rubyzip (>= 1.2.2, < 3.0)
249249
websocket (~> 1.0)
250+
sentry-rails (5.4.1)
251+
railties (>= 5.0)
252+
sentry-ruby (~> 5.4.1)
253+
sentry-ruby (5.4.1)
254+
concurrent-ruby (~> 1.0, >= 1.0.2)
250255
simplecov (0.21.2)
251256
docile (~> 1.1)
252257
simplecov-html (~> 0.11)
@@ -326,6 +331,8 @@ DEPENDENCIES
326331
rubocop
327332
rubocop-rails
328333
selenium-webdriver
334+
sentry-rails
335+
sentry-ruby
329336
simplecov
330337
simplecov-lcov
331338
sprockets-rails

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ change as part of the work.
5353
`basic_search#index`.
5454
- `GLOBAL_ALERT`: The main functionality for this comes from our theme gem, but when set the value will be rendered as
5555
safe html above the main header of the site.
56+
- `SENTRY_DSN`: Client key for Sentry exception logging.
57+
- `SENTRY_ENV`: Sentry environment for the application. Defaults to 'unknown' if unset.
5658
- `TIMDEX_INDEX`: Name of the index, or alias, to provide to the GraphQL endpoint. Defaults to `nil` which will let TIMDEX determine the best index to use. Wildcard values can be set, for example `rdi*` would search any indexes that begin with `rdi` in the underlying OpenSearch instance behind TIMDEX.
5759
- `TIMDEX_SOURCES`: Comma-separated list of sources to display in the advanced-search source selection element. This
5860
overrides the default which is set in ApplicationHelper.

config/initializers/sentry.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Sentry.init do |config|
2+
return unless ENV.has_key?('SENTRY_DSN')
3+
config.dsn = ENV.fetch('SENTRY_DSN')
4+
config.breadcrumbs_logger = [:active_support_logger, :http_logger]
5+
config.environment = ENV.fetch('SENTRY_ENV', 'unknown')
6+
end

0 commit comments

Comments
 (0)