Class: ChefHandlerStatsd
- Inherits:
-
Chef::Handler
- Object
- Chef::Handler
- ChefHandlerStatsd
- Defined in:
- lib/chef-handler-statsd.rb
Instance Method Summary collapse
-
#initialize(host = 'localhost', port = 8125) ⇒ ChefHandlerStatsd
constructor
A new instance of ChefHandlerStatsd.
- #report ⇒ Object
Constructor Details
#initialize(host = 'localhost', port = 8125) ⇒ ChefHandlerStatsd
Returns a new instance of ChefHandlerStatsd.
7 8 9 |
# File 'lib/chef-handler-statsd.rb', line 7 def initialize(host = 'localhost', port = 8125) @statsd = Datadog::Statsd.new(host, port) end |
Instance Method Details
#report ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/chef-handler-statsd.rb', line 11 def report = { nodeName: node.name } @statsd.count('chef-client.total_runs', 1, tags: ) @statsd.timing('chef-client.run_time', run_status.elapsed_time * 1000, tags: ) @statsd.count('chef-client.total_resources', run_status.all_resources.length, tags: ) @statsd.count('chef-client.updated_resources', run_status.updated_resources.length, tags: ) if run_status.failed? @statsd.count('chef-client.failed_runs', tags: ) else @statsd.count('chef-client.success_runs', tags: ) end end |