Class: StackDriverHandler
- Inherits:
-
Chef::Handler
- Object
- Chef::Handler
- StackDriverHandler
- Defined in:
- lib/chef/handler/stackdriver.rb,
lib/chef/handler/stackdriver/version.rb
Constant Summary collapse
- VERSION =
"0.1.2"
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ StackDriverHandler
constructor
A new instance of StackDriverHandler.
- #report ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ StackDriverHandler
Returns a new instance of StackDriverHandler.
24 25 26 27 28 29 30 |
# File 'lib/chef/handler/stackdriver.rb', line 24 def initialize(opts = {}) @options = { :instance_id => nil, :stackdriver_api => nil } @options.merge! opts end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
23 24 25 |
# File 'lib/chef/handler/stackdriver.rb', line 23 def @options end |
Instance Method Details
#report ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/chef/handler/stackdriver.rb', line 32 def report if ![:instance_id] Chef::Log.error "StackDriverHandler: No instance_id provided. No information sent to StackDriver." elsif ![:stackdriver_api] Chef::Log.error "StackDriverHandler: No stackdriver_api provided. No information sent to StackDriver." else status = success? ? 1 : 0 date = Time.now.to_i StackDriver.init [:stackdriver_api] StackDriver.send_metric 'chef_status', status, date, [:instance_id] if success? StackDriver.send_metric 'chef_run_time', run_data[:elapsed_time].to_s, date, [:instance_id] StackDriver.send_metric 'chef_resources_updated', run_data[:updated_resources].length, date, [:instance_id] end Chef::Log.debug "StackDriverHandler: Metrics sent." end end |