Class: Metrician::Honeybadger

Inherits:
Reporter
  • Object
show all
Defined in:
lib/metrician/reporters/honeybadger.rb

Constant Summary collapse

EXCEPTION_METRIC =
"tracked_exception"

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Reporter

all, inherited

Class Method Details

.enabled?Boolean

Returns:

  • (Boolean)


6
7
8
9
# File 'lib/metrician/reporters/honeybadger.rb', line 6

def self.enabled?
  !!defined?(::Honeybadger) &&
    Metrician.configuration[:exception][:enabled]
end

Instance Method Details

#instrumentObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/metrician/reporters/honeybadger.rb', line 11

def instrument
  return if ::Honeybadger::Agent.method_defined?(:notify_with_metrician)
  ::Honeybadger::Agent.class_eval do
    def notify_with_metrician(exception, options = {})
      # We can differentiate whether or not we live inside a web
      # request or not by determining the nil-ness of:
      #   context_manager.get_rack_env
      notify_without_metrician(exception, options)
    ensure
      Metrician.increment(EXCEPTION_METRIC) if Metrician.configuration[:exception][:raise][:enabled]
      # TODO: underscore is rails only
      Metrician.increment("#{EXCEPTION_METRIC}.#{Metrician.dotify(exception.class.name.underscore)}") if exception && Metrician.configuration[:exception][:exception_specific][:enabled]
    end
    alias_method :notify_without_metrician, :notify
    alias_method :notify, :notify_with_metrician
  end
end