From 956657d586078660f2218e2e7c71f566729af16c Mon Sep 17 00:00:00 2001 From: Greg Meyer Date: Mon, 9 May 2016 16:59:02 -0400 Subject: [PATCH 1/2] adds hostname to the arguments passed to the gem --- recipes/dd-handler.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/recipes/dd-handler.rb b/recipes/dd-handler.rb index bfd48197..9ce828cf 100644 --- a/recipes/dd-handler.rb +++ b/recipes/dd-handler.rb @@ -53,7 +53,8 @@ :api_key => node['datadog']['api_key'], :application_key => node['datadog']['application_key'], :use_ec2_instance_id => node['datadog']['use_ec2_instance_id'], - :tag_prefix => node['datadog']['tag_prefix'] + :tag_prefix => node['datadog']['tag_prefix'], + :hostname => node['datadog']['hostname'] ] supports :report => true, :exception => true action :nothing From 07dd540987d87023aab32e5090261ccaa1070312 Mon Sep 17 00:00:00 2001 From: Greg Meyer Date: Wed, 8 Jun 2016 11:19:03 -0400 Subject: [PATCH 2/2] if use ec2 hostname is set, hostname won't be passed to handler --- recipes/dd-handler.rb | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/recipes/dd-handler.rb b/recipes/dd-handler.rb index 9ce828cf..f85641df 100644 --- a/recipes/dd-handler.rb +++ b/recipes/dd-handler.rb @@ -46,16 +46,21 @@ ENV['DATADOG_PROXY'] = proxy_url.to_s end +handler_config = { + :api_key => node['datadog']['api_key'], + :application_key => node['datadog']['application_key'], + :use_ec2_instance_id => node['datadog']['use_ec2_instance_id'], + :tag_prefix => node['datadog']['tag_prefix'] +} + +unless node['datadog']['use_ec2_instance_id'] + handler_config[:hostname] = node['datadog']['hostname'] +end + # Create the handler to run at the end of the Chef execution chef_handler 'Chef::Handler::Datadog' do source 'chef/handler/datadog' - arguments [ - :api_key => node['datadog']['api_key'], - :application_key => node['datadog']['application_key'], - :use_ec2_instance_id => node['datadog']['use_ec2_instance_id'], - :tag_prefix => node['datadog']['tag_prefix'], - :hostname => node['datadog']['hostname'] - ] + arguments [handler_config] supports :report => true, :exception => true action :nothing end.run_action(:enable) if node['datadog']['chef_handler_enable']