Class: Monitoring::Client::Profiler
- Inherits:
-
Object
- Object
- Monitoring::Client::Profiler
- Defined in:
- lib/monitoring/client/profiler.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#decorations ⇒ Object
Returns the value of attribute decorations.
-
#program_name ⇒ Object
Returns the value of attribute program_name.
Instance Method Summary collapse
- #compile(routine) ⇒ Object
- #default_decorations ⇒ Object
-
#initialize(program_name, decorations = {}) ⇒ Profiler
constructor
A new instance of Profiler.
- #json_encode(what) ⇒ Object
- #post_metrics(compiled) ⇒ Object
- #routine(routine_name) {|routine| ... } ⇒ Object
Constructor Details
#initialize(program_name, decorations = {}) ⇒ Profiler
Returns a new instance of Profiler.
13 14 15 16 17 |
# File 'lib/monitoring/client/profiler.rb', line 13 def initialize(program_name, decorations = {}) self.config = Config.global self.program_name = program_name self.decorations = default_decorations.merge(decorations) end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
11 12 13 |
# File 'lib/monitoring/client/profiler.rb', line 11 def config @config end |
#decorations ⇒ Object
Returns the value of attribute decorations.
11 12 13 |
# File 'lib/monitoring/client/profiler.rb', line 11 def decorations @decorations end |
#program_name ⇒ Object
Returns the value of attribute program_name.
11 12 13 |
# File 'lib/monitoring/client/profiler.rb', line 11 def program_name @program_name end |
Instance Method Details
#compile(routine) ⇒ Object
28 29 30 |
# File 'lib/monitoring/client/profiler.rb', line 28 def compile(routine) Compiler.compile(self, routine) end |
#default_decorations ⇒ Object
41 42 43 44 45 46 |
# File 'lib/monitoring/client/profiler.rb', line 41 def default_decorations { :hostname => config.hostname, :hostgroup => config.hostgroup, } end |
#json_encode(what) ⇒ Object
37 38 39 |
# File 'lib/monitoring/client/profiler.rb', line 37 def json_encode(what) Yajl::Encoder.encode(what) end |
#post_metrics(compiled) ⇒ Object
32 33 34 35 |
# File 'lib/monitoring/client/profiler.rb', line 32 def post_metrics(compiled) UDPSocket.new().send(json_encode(compiled) + "\n", 0, "localhost", 57475) end |