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, tags = {}) ⇒ ChefHandlerStatsd
constructor
A new instance of ChefHandlerStatsd.
- #report ⇒ Object
Constructor Details
#initialize(host = 'localhost', port = 8125, tags = {}) ⇒ ChefHandlerStatsd
Returns a new instance of ChefHandlerStatsd.
7 8 9 10 |
# 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
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/chef-handler-statsd.rb', line 12 def report = { nodeName: node.name } .merge!() @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', 1, tags: ) else @statsd.count('chef-client.success_runs', 1, tags: ) end end |