Sha256: 75857c400cc769549ce402a5ab8a132d39e29243b58bf73f38c8f319e0436d02

Contents?: true

Size: 569 Bytes

Versions: 6

Compression:

Stored size: 569 Bytes

Contents

module Phobos
  module Instrumentation
    NAMESPACE = 'phobos'

    def instrument(event, extra = {})
      ActiveSupport::Notifications.instrument("#{NAMESPACE}.#{event}", extra) do |extra|
        yield(extra) if block_given?
      end
    end

    def self.subscribe(event)
      ActiveSupport::Notifications.subscribe("#{NAMESPACE}.#{event}") do |*args|
        yield ActiveSupport::Notifications::Event.new(*args) if block_given?
      end
    end

    def self.unsubscribe(subscriber)
      ActiveSupport::Notifications.unsubscribe(subscriber)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
phobos-1.4.2 lib/phobos/instrumentation.rb
phobos-1.4.1 lib/phobos/instrumentation.rb
phobos-1.4.0 lib/phobos/instrumentation.rb
phobos-1.3.0 lib/phobos/instrumentation.rb
phobos-1.2.1 lib/phobos/instrumentation.rb
phobos-1.2.0 lib/phobos/instrumentation.rb