Class: Upfluence::ErrorLogger::Sentry

Inherits:
Object
  • Object
show all
Defined in:
lib/upfluence/error_logger/sentry.rb

Constant Summary collapse

EXCLUDED_ERRORS =
(Raven::Configuration::IGNORE_DEFAULT + ['Identity::Thrift::Forbidden']).freeze

Instance Method Summary collapse

Constructor Details

#initializeSentry

Returns a new instance of Sentry.



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/upfluence/error_logger/sentry.rb', line 8

def initialize
  ::Raven.configure do |config|
    config.dsn = ENV['SENTRY_DSN']
    config.current_environment = Upfluence.env
    config.excluded_exceptions = EXCLUDED_ERRORS
    config.logger = Upfluence.logger
    config.release = "#{ENV['PROJECT_NAME']}-#{ENV['SEMVER_VERSION']}"
    config.tags = {
      unit_name: unit_name,
      unit_type: unit_type
    }.select { |_, v| !v.nil? }
  end
end

Instance Method Details

#middlewareObject



34
35
36
# File 'lib/upfluence/error_logger/sentry.rb', line 34

def middleware
  ::Raven::Rack
end

#notify(error, method, *args) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/upfluence/error_logger/sentry.rb', line 22

def notify(error, method, *args)
  Raven.capture_exception(
    error,
    extra: { method: method, arguments: args },
    tags: { method: method }
  )
end

#user=(user) ⇒ Object



30
31
32
# File 'lib/upfluence/error_logger/sentry.rb', line 30

def user=(user)
  Raven.user_context(id: user.id, email: user.email)
end