chef-handler-datadog 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.8.7
4
3
  - 1.9.3
5
- env:
6
- - CHEF_VERSION=0.10.8
7
- - CHEF_VERSION=10.12.0
8
- - CHEF_VERSION=10.14.2
4
+ before_install: gem update --system 1.8.25
5
+ gemfile:
6
+ - gemfiles/Gemfile.chef-11
7
+ - gemfiles/Gemfile.chef-10
@@ -1,9 +1,6 @@
1
- # -*- encoding: utf-8 -*-
2
- chef_version = ENV.key?('CHEF_VERSION') ? "= #{ENV['CHEF_VERSION']}" : ['~> 10.12']
3
1
  require File.expand_path('../lib/chef-handler-datadog', __FILE__)
4
2
 
5
3
  Gem::Specification.new do |gem|
6
-
7
4
  gem.name = "chef-handler-datadog"
8
5
  gem.summary = %q{Chef Handler for DataDog events and metrics}
9
6
  gem.description = %q{This Handler will report the events and metrics for a chef-client run to DataDog.}
@@ -16,7 +13,7 @@ Gem::Specification.new do |gem|
16
13
  gem.require_paths = ['lib']
17
14
  gem.extra_rdoc_files = ['README.md', 'LICENSE.txt']
18
15
 
19
- gem.add_dependency 'chef', chef_version
16
+ gem.add_dependency 'chef', ">= 10", "<= 12"
20
17
  gem.add_dependency 'dogapi', ">= 1.2"
21
18
 
22
19
  gem.add_development_dependency 'rake'
@@ -26,7 +23,6 @@ Gem::Specification.new do |gem|
26
23
  gem.add_development_dependency 'travis-lint'
27
24
 
28
25
  gem.authors = ["Mike Fiedler", "Adam Jacob", "Alexis Le-Quoc"]
29
- gem.email = ["packages@datadoghq.com"]
26
+ gem.email = ["package@datadoghq.com"]
30
27
  gem.homepage = "http://www.datadoghq.com/"
31
-
32
28
  end
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'chef', '~> 10.0'
4
+
5
+ gemspec :path => '..'
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'chef', '~> 11.2'
4
+
5
+ gemspec :path => '..'
@@ -1,3 +1,3 @@
1
1
  module ChefHandlerDatadog
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -92,38 +92,44 @@ class Chef
92
92
 
93
93
  # Get the current list of tags, remove any "role:" entries
94
94
  host_tags = @dog.host_tags(hostname)[1]["tags"] || []
95
- host_tags.delete_if {|tag| tag.start_with?('role:') }
95
+ host_tags.delete_if { |tag| tag.start_with?('role:') }
96
96
 
97
97
  # Get list of chef roles, rename them to tag format
98
98
  chef_roles = node.run_list.roles
99
- chef_roles.collect! {|role| "role:" + role }
99
+ chef_roles.collect! { |role| "role:" + role }
100
100
 
101
101
  # Get the chef environment (as long as it's not '_default')
102
102
  if node.respond_to?('chef_environment') && node.chef_environment != '_default'
103
- host_tags.delete_if {|tag| tag.start_with?('env:') }
103
+ host_tags.delete_if { |tag| tag.start_with?('env:') }
104
104
  host_tags << "env:" + node.chef_environment
105
105
  end
106
106
 
107
107
  # Combine (union) both arrays. Removes dupes, preserves non-chef tags.
108
108
  new_host_tags = host_tags | chef_roles
109
109
 
110
- # Replace all tags with the new tags
111
- rc = @dog.update_tags(hostname, new_host_tags)
112
- begin
113
- # See FIXME above about why I feel dirty repeating this code here
114
- if evt.length < 2
115
- Chef::Log.warn("Unexpected response from Datadog Event API: #{evt}")
116
- else
117
- if rc[0].to_i / 100 != 2
118
- Chef::Log.warn("Could not submit #{chef_roles} tags for #{hostname} to Datadog")
110
+ if @application_key.nil?
111
+ Chef::Log.warn("You need an application key to let Chef tag your nodes " \
112
+ "in Datadog. Visit https://app.datadoghq.com/account/settings#api to " \
113
+ "create one and update your datadog attributes in the datadog cookbook."
114
+ )
115
+ else
116
+ # Replace all tags with the new tags
117
+ rc = @dog.update_tags(hostname, new_host_tags)
118
+ begin
119
+ # See FIXME above about why I feel dirty repeating this code here
120
+ if rc.length < 2
121
+ Chef::Log.warn("Unexpected response from Datadog Event API: #{evt}")
119
122
  else
120
- Chef::Log.debug("Successfully updated #{hostname}'s tags to #{new_host_tags.join(', ')}")
123
+ if rc[0].to_i / 100 != 2
124
+ Chef::Log.warn("Could not submit #{chef_roles} tags for #{hostname} to Datadog")
125
+ else
126
+ Chef::Log.debug("Successfully updated #{hostname}'s tags to #{new_host_tags.join(', ')}")
127
+ end
121
128
  end
129
+ rescue
130
+ Chef::Log.warn("Could not determine whether #{hostname}'s tags were successfully submitted to Datadog: #{rc}")
122
131
  end
123
- rescue
124
- Chef::Log.warn("Could not determine whether #{hostname}'s tags were successfully submitted to Datadog: #{rc}")
125
132
  end
126
-
127
133
  rescue Errno::ECONNREFUSED, Errno::ETIMEDOUT => e
128
134
  Chef::Log.error("Could not connect to Datadog. Connection error:\n" + e)
129
135
  Chef::Log.error("Data to be submitted was:")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-handler-datadog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,24 +11,30 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2012-09-27 00:00:00.000000000 Z
14
+ date: 2013-04-03 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: chef
18
18
  requirement: !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
- - - ~>
21
+ - - ! '>='
22
+ - !ruby/object:Gem::Version
23
+ version: '10'
24
+ - - <=
22
25
  - !ruby/object:Gem::Version
23
- version: '10.12'
26
+ version: '12'
24
27
  type: :runtime
25
28
  prerelease: false
26
29
  version_requirements: !ruby/object:Gem::Requirement
27
30
  none: false
28
31
  requirements:
29
- - - ~>
32
+ - - ! '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '10'
35
+ - - <=
30
36
  - !ruby/object:Gem::Version
31
- version: '10.12'
37
+ version: '12'
32
38
  - !ruby/object:Gem::Dependency
33
39
  name: dogapi
34
40
  requirement: !ruby/object:Gem::Requirement
@@ -128,7 +134,7 @@ dependencies:
128
134
  description: This Handler will report the events and metrics for a chef-client run
129
135
  to DataDog.
130
136
  email:
131
- - packages@datadoghq.com
137
+ - package@datadoghq.com
132
138
  executables: []
133
139
  extensions: []
134
140
  extra_rdoc_files:
@@ -142,6 +148,8 @@ files:
142
148
  - README.md
143
149
  - Rakefile
144
150
  - chef-handler-datadog.gemspec
151
+ - gemfiles/Gemfile.chef-10
152
+ - gemfiles/Gemfile.chef-11
145
153
  - lib/chef-handler-datadog.rb
146
154
  - lib/chef/handler/datadog.rb
147
155
  - test/helper.rb