Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add and configure Sentry gem #146

Merged
merged 2 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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