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-2.1.6 lib/phobos/instrumentation.rb
phobos-2.1.5 lib/phobos/instrumentation.rb
phobos-2.1.4 lib/phobos/instrumentation.rb
phobos-2.1.3 lib/phobos/instrumentation.rb
phobos-2.1.2 lib/phobos/instrumentation.rb
phobos-2.1.1 lib/phobos/instrumentation.rb
phobos_temp_fork-0.0.4 lib/phobos/instrumentation.rb
phobos_temp_fork-0.0.3 lib/phobos/instrumentation.rb
phobos_temp_fork-0.0.2 lib/phobos/instrumentation.rb
phobos_temp_fork-0.0.1 lib/phobos/instrumentation.rb
phobos-2.1.0 lib/phobos/instrumentation.rb
phobos-2.0.2 lib/phobos/instrumentation.rb
phobos-2.0.1 lib/phobos/instrumentation.rb
phobos-2.0.0.pre.beta1 lib/phobos/instrumentation.rb
phobos-1.9.0 lib/phobos/instrumentation.rb
phobos-1.9.0.pre.beta3 lib/phobos/instrumentation.rb
phobos-1.9.0.pre.beta2 lib/phobos/instrumentation.rb
phobos-1.9.0.pre.beta1 lib/phobos/instrumentation.rb
phobos-1.8.3.pre.beta2 lib/phobos/instrumentation.rb
phobos-1.8.3.pre.beta1 lib/phobos/instrumentation.rb