Class: Sentry::Scrubbers::LogAsWarning

Inherits:
Object
  • Object
show all
Defined in:
lib/sentry/scrubbers/log_as_warning.rb

Constant Summary collapse

SENTRY_LOG_LEVEL_WARNING =
30
RELEVANT_EXCEPTIONS =
[
  Common::Exceptions::GatewayTimeout,
  EVSS::ErrorMiddleware::EVSSError
].freeze

Instance Method Summary collapse

Instance Method Details

#get_exception_class(data) ⇒ Object (private)



40
41
42
# File 'lib/sentry/scrubbers/log_as_warning.rb', line 40

def get_exception_class(data)
  data['exception']['values'].last['type'].constantize
end

#process(data) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/sentry/scrubbers/log_as_warning.rb', line 18

def process(data)
  stringified_data = data.deep_stringify_keys
  return stringified_data if stringified_data['exception'].blank?
  return set_warning_level(stringified_data) if stringified_data['extra'].try(:[], 'log_as_warning')

  exception_class = get_exception_class(stringified_data)

  RELEVANT_EXCEPTIONS.each do |relevant_exception|
    return set_warning_level(stringified_data) if exception_class <= relevant_exception
  end

  stringified_data
end

#set_warning_level(data) ⇒ Object (private)



34
35
36
37
38
# File 'lib/sentry/scrubbers/log_as_warning.rb', line 34

def set_warning_level(data)
  data['level'] = SENTRY_LOG_LEVEL_WARNING

  data
end