module AirbrakeProxy
Constants
- KEY_PREFIX
- THRESHOLD
- VERSION
Public Instance Methods
clean!()
click to toggle source
# File lib/airbrake_proxy.rb, line 32 def clean! _keys.each { |key| RedisProxy.del(key) } end
keys()
click to toggle source
# File lib/airbrake_proxy.rb, line 28 def keys _keys.map { |key| [key, RedisProxy.get(key)] } end
notify(exception, params)
click to toggle source
# File lib/airbrake_proxy.rb, line 16 def notify(exception, params) unless exception logger.error("AirbrakeProxy#notify(#{exception}, #{params}) => called without exception") return false end safe_notify(exception) { Airbrake.notify(exception, params) } true rescue TooManyNotification => e logger.info("AirbrakeProxy => #{e.message}") end
remove(key)
click to toggle source
# File lib/airbrake_proxy.rb, line 36 def remove(key) if key.match(KEY_PREFIX) RedisProxy.del(key) == 1 ? true : false else false end end
Private Instance Methods
_keys()
click to toggle source
# File lib/airbrake_proxy.rb, line 50 def _keys RedisProxy.keys.select { |key| key.match(KEY_PREFIX) } end
key(exception_or_message)
click to toggle source
# File lib/airbrake_proxy.rb, line 66 def key(exception_or_message) msg = case exception_or_message when String exception_or_message when StandardError, Exception exception_or_message.message else exception_or_message.to_s end "#{KEY_PREFIX}#{msg.parameterize}" end
logger()
click to toggle source
# File lib/airbrake_proxy.rb, line 94 def logger @logger ||= AirbrakeProxy.configuration.logger end
mark_as_notify!(key)
click to toggle source
# File lib/airbrake_proxy.rb, line 84 def mark_as_notify!(key) RedisProxy.multi RedisProxy.incr(key) RedisProxy.expire(key, T_1_HOUR) RedisProxy.exec nil end
safe_notify(exception) { || ... }
click to toggle source
# File lib/airbrake_proxy.rb, line 56 def safe_notify(exception) redis_key = key(exception) unless authorized_to_notify?(redis_key) raise TooManyNotification.new("#{redis_key} was notified too many times") end yield end