Sha256: 02857520cf4efa39a29609a8c088d9b7b5eb5521ffedc19dc24bac163eed7223

Contents?: true

Size: 638 Bytes

Versions: 24

Compression:

Stored size: 638 Bytes

Contents

# frozen_string_literal: true

require 'active_support/notifications'

module Phobos
  module Instrumentation
    NAMESPACE = 'phobos'

    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

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

Version data entries

24 entries across 24 versions & 2 rubygems

Version Path
phobos-1.8.2 lib/phobos/instrumentation.rb
phobos-1.8.2.pre.beta2 lib/phobos/instrumentation.rb
phobos-1.8.2.pre.beta1 lib/phobos/instrumentation.rb
phobos-1.8.1 lib/phobos/instrumentation.rb