Class: Puppet::Util::Instrumentation::Data

Inherits:
Object
  • Object
show all
Extended by:
Indirector
Defined in:
lib/vendor/puppet/util/instrumentation/data.rb

Overview

This is just a transport class to be used through the instrumentation_data indirection. All the data resides in the real underlying listeners which this class delegates to.

Constant Summary

Constants included from Indirector

Indirector::BadNameRegexp

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Indirector

configure_routes, indirects

Constructor Details

#initialize(listener_name) ⇒ Data

Returns a new instance of Data.



14
15
16
17
# File 'lib/vendor/puppet/util/instrumentation/data.rb', line 14

def initialize(listener_name)
  @listener = Puppet::Util::Instrumentation[listener_name]
  raise "Listener #{listener_name} wasn't registered" unless @listener
end

Instance Attribute Details

#listenerObject (readonly)

Returns the value of attribute listener.



12
13
14
# File 'lib/vendor/puppet/util/instrumentation/data.rb', line 12

def listener
  @listener
end

Class Method Details

.from_pson(data) ⇒ Object



31
32
33
# File 'lib/vendor/puppet/util/instrumentation/data.rb', line 31

def self.from_pson(data)
  data
end

Instance Method Details

#nameObject



19
20
21
# File 'lib/vendor/puppet/util/instrumentation/data.rb', line 19

def name
  @listener.name
end

#to_pson(*args) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/vendor/puppet/util/instrumentation/data.rb', line 23

def to_pson(*args)
  result = {
    'document_type' => "Puppet::Util::Instrumentation::Data",
    'data' => { :name => name }.merge(@listener.respond_to?(:data) ? @listener.data : {})
  }
  result.to_pson(*args)
end