class Puppet::Util::Instrumentation::Listener

Attributes

enabled[RW]
listener[R]
pattern[R]

Public Instance Methods

data() click to toggle source
# File lib/puppet/util/instrumentation/listener.rb, line 40
def data
  { :data => @listener.data }
end
enabled?() click to toggle source
# File lib/puppet/util/instrumentation/listener.rb, line 32
def enabled?
  !!@enabled
end
listen_to?(label) click to toggle source
# File lib/puppet/util/instrumentation/listener.rb, line 28
def listen_to?(label)
  enabled? and (!@pattern || @pattern === label.to_s)
end
name() click to toggle source
# File lib/puppet/util/instrumentation/listener.rb, line 36
def name
  @listener.name.to_s
end
notify(label, event, data) click to toggle source
# File lib/puppet/util/instrumentation/listener.rb, line 22
def notify(label, event, data)
  listener.notify(label, event, data)
rescue => e
  warnonce("Error during instrumentation notification: #{e}")
end
to_data_hash() click to toggle source
# File lib/puppet/util/instrumentation/listener.rb, line 44
def to_data_hash
  {
    :name => name,
    :pattern => pattern,
    :enabled => enabled?
  }
end
to_pson(*args) click to toggle source
# File lib/puppet/util/instrumentation/listener.rb, line 59
def to_pson(*args)
  to_pson_data_hash.to_pson(*args)
end
to_pson_data_hash() click to toggle source
# File lib/puppet/util/instrumentation/listener.rb, line 52
def to_pson_data_hash
  {
    :document_type => "Puppet::Util::Instrumentation::Listener",
    :data => to_data_hash,
  }
end

Public Class Methods

from_data_hash(data) click to toggle source
# File lib/puppet/util/instrumentation/listener.rb, line 63
def self.from_data_hash(data)
  result = Puppet::Util::Instrumentation[data["name"]]
  self.new(result.listener, result.pattern, data["enabled"])
end
from_pson(data) click to toggle source
# File lib/puppet/util/instrumentation/listener.rb, line 68
def self.from_pson(data)
  Puppet.deprecation_warning("from_pson is being removed in favour of from_data_hash.")
  self.from_data_hash(data)
end
new(listener, pattern = nil, enabled = false) click to toggle source
# File lib/puppet/util/instrumentation/listener.rb, line 15
def initialize(listener, pattern = nil, enabled = false)
  @pattern = pattern.is_a?(Symbol) ? pattern.to_s : pattern
  raise "Listener isn't a correct listener (it doesn't provide the notify method)" unless listener.respond_to?(:notify)
  @listener = listener
  @enabled = enabled
end