class Upfluence::ErrorLogger::Sentry

Constants

EXCLUDED_ERRORS

Public Class Methods

new() click to toggle source
# 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

Public Instance Methods

ignore_exception(*klss) click to toggle source
# File lib/upfluence/error_logger/sentry.rb, line 42
def ignore_exception(*klss)
  klss.each do |kls|
    puts kls
    case kls.class
    when Class
      Raven.configuration.excluded_exceptions << kls.name
    when String
      Raven.configuration.excluded_exceptions << kls
    else
      Upfluence.logger.warn e.message
    end
  end
end
middleware() click to toggle source
# File lib/upfluence/error_logger/sentry.rb, line 38
def middleware
  ::Raven::Rack
end
notify(error, method, *args) click to toggle source
# File lib/upfluence/error_logger/sentry.rb, line 22
def notify(error, method, *args)
  begin
    Raven.capture_exception(
      error,
      extra: { method: method, arguments: args.map(&:inspect) },
      tags: { method: method }
    )
  rescue Raven::Error => e
    Upfluence.logger.error e.message
  end
end
user=(user) click to toggle source
# File lib/upfluence/error_logger/sentry.rb, line 34
def user=(user)
  Raven.user_context(id: user.id, email: user.email)
end

Private Instance Methods

unit_name() click to toggle source
# File lib/upfluence/error_logger/sentry.rb, line 58
def unit_name
  ENV['UNIT_NAME'].split('.').first if ENV['UNIT_NAME']
end
unit_type() click to toggle source
# File lib/upfluence/error_logger/sentry.rb, line 62
def unit_type
  unit_name.split('@').first if unit_name
end