Sha256: fab2aad6dc8154026396aedc96d6d1116eee8606c41891f73da461c48719f8db

Contents?: true

Size: 954 Bytes

Versions: 15

Compression:

Stored size: 954 Bytes

Contents

class Circuitbox
  class Notifier
    def initialize(service, partition=nil)
      @service   = service
      @partition = partition
    end

    def notify(event)
      return unless notification_available?
      ActiveSupport::Notifications.instrument("circuit_#{event}", circuit: circuit_name)
    end

    def notify_warning(message)
      return unless notification_available?
      ActiveSupport::Notifications.instrument("circuit_warning", { circuit: circuit_name, message: message})
    end

    def metric_gauge(gauge, value)
      return unless notification_available?
      ActiveSupport::Notifications.instrument("circuit_gauge", { circuit: circuit_name, gauge: gauge.to_s, value: value })
    end

    private
    def circuit_name
      circuit_name = @service.to_s
      circuit_name += ":#{@partition}" if @partition
      circuit_name
    end

    def notification_available?
      defined? ActiveSupport::Notifications
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
circuitbox-1.1.1 lib/circuitbox/notifier.rb
circuitbox-1.1.0 lib/circuitbox/notifier.rb
circuitbox-1.0.3 lib/circuitbox/notifier.rb
circuitbox-1.0.2 lib/circuitbox/notifier.rb
circuitbox-1.0.1 lib/circuitbox/notifier.rb
circuitbox-1.0.0 lib/circuitbox/notifier.rb
circuitbox-0.11.0 lib/circuitbox/notifier.rb
circuitbox-0.10.4 lib/circuitbox/notifier.rb
circuitbox-0.10.3 lib/circuitbox/notifier.rb
circuitbox-0.10.2 lib/circuitbox/notifier.rb
circuitbox-0.10.1 lib/circuitbox/notifier.rb
circuitbox-0.10.0 lib/circuitbox/notifier.rb
circuitbox-0.9.0 lib/circuitbox/notifier.rb
circuitbox-0.8.0 lib/circuitbox/notifier.rb
circuitbox-0.7.0 lib/circuitbox/notifier.rb