Skip to content

Commit

Permalink
Rescue all errors when sending/emitting from the handler (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
borgstrom authored and olivielpeau committed Oct 22, 2019
1 parent 90eed9a commit 452d133
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
14 changes: 14 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,17 @@ If you'd like to run the test suite, fix a bug or add a feature, please follow t
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
* Please try not to mess with the `Rakefile`, version, or history.
If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.


## Building and using local snapshots

Sometimes you need to test chef-handler-datadog before a fix is merged. In this case you need to:

* Set the version in `lib/chef_handler_datadog.rb`
If the current version is `0.11.0` then you should bump to `0.11.1.pre`.
This way when the next version is released it will take precedence over your snapshot.
* Run `rake build`, this will create the .gem file in the `pkg/` dir
* Copy the .gem file to your own gem server
* When you include `datadog::dd-handler` in your Chef runlist set `node.override['datadog']['gem_server']` to your gem server URL and `node.override['datadog']['chef_handler_version']` to your `.pre` version.
* Chef will install your version of the gem
* Don't forget to unset `gem_server` and `chef_handler_version` once the handler has been released with your changes
8 changes: 4 additions & 4 deletions lib/chef/handler/datadog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ def send_report_to_datadog(dog)
@metrics.emit_to_datadog dog
@event.emit_to_datadog dog
@tags.send_update_to_datadog dog
rescue Errno::ECONNREFUSED, Errno::ETIMEDOUT => e
Chef::Log.error("Could not connect to Datadog. Connection error:\n" + e)
Chef::Log.error('Data to be submitted was:')
rescue => e
Chef::Log.error("Could not send/emit to Datadog:\n" + e)
Chef::Log.error('Event data to be submitted was:')
Chef::Log.error(@event.event_title)
Chef::Log.error(@event.event_body)
Chef::Log.error('Tags to be set for this run:')
Expand Down Expand Up @@ -134,7 +134,7 @@ def prepare_the_pack
app_key,
nil, # host
nil, # device
true, # silent
false, # silent
nil, # timeout
url
))
Expand Down

0 comments on commit 452d133

Please sign in to comment.