fluent-plugin-dd 0.1.5 → 0.1.6

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8abcfb0fc04ae21036b74510e140eb471c583ec1
4
- data.tar.gz: bb1cd7f2340cb5d14a5fcafed9ab58d13923afd0
3
+ metadata.gz: a97e3d33021af7a03dc9bd0ae1f2431332260e03
4
+ data.tar.gz: 4bd8cb8de1663d893aac826f08bd1d314ca30add
5
5
  SHA512:
6
- metadata.gz: 0be3eeb5ba3ee78de16a52c597031d4ee943771bed50743f6ccf60a8058f1e0077a40742ea9efa09e4fd693326a71afbae55a7d250920eca807ada8fb6db49a3
7
- data.tar.gz: 0235abf277ff35648cfdcbff3a05219a78cfa1c147a0bc1eb144c57aae27ad5a5938cd9711f7fbd9bd14599d9c8a5ecd205ea7e809ff07a8673ee985fd0944a1
6
+ metadata.gz: 2e9402d2f8ba77fbb235a2406680139e05e77b2f8ceaf570811ef616fc44e4b5cdb3c3edeaf31bec1fef2566f0b1723800983489b49e9c2bbdef5573e5ae24a2
7
+ data.tar.gz: 58c07c32af366a4eea8087443a39f58c43e7c740a1f9f7f26e4babe771a63f6273d216fa3569425fb575b3fb287fee77853dfd9c258267b676fe80ffde6e2230
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ script:
5
+ - bundle install
6
+ - bundle exec rake
data/README.md CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  Output plugin for Datadog
4
4
 
5
- [![Gem Version](https://badge.fury.io/rb/fluent-plugin-dd.png)](http://badge.fury.io/rb/fluent-plugin-dd)
6
- [![Build Status](https://drone.io/bitbucket.org/winebarrel/fluent-plugin-dd/status.png)](https://drone.io/bitbucket.org/winebarrel/fluent-plugin-dd/latest)
5
+ [![Gem Version](https://badge.fury.io/rb/fluent-plugin-dd.svg)](http://badge.fury.io/rb/fluent-plugin-dd)
6
+ [![Build Status](https://travis-ci.org/winebarrel/fluent-plugin-dd.svg?branch=master)](https://travis-ci.org/winebarrel/fluent-plugin-dd)
7
7
 
8
8
  ## Installation
9
9
 
@@ -15,7 +15,11 @@ Output plugin for Datadog
15
15
  <match datadog.**>
16
16
  type dd
17
17
  dd_api_key ...
18
+ #dd_app_key_key ...
18
19
  #host my_host.example.com
20
+ #device my_device
21
+ #silent true
22
+ #timeout 5
19
23
  #use_fluentd_tag_for_datadog_tag false
20
24
  #emit_in_background false
21
25
  </match>
@@ -25,7 +29,7 @@ Output plugin for Datadog
25
29
 
26
30
  ```sh
27
31
  echo '{"metric":"some.metric.name", "value":50.0}' | fluent-cat datadog.metric
28
- echo '{"metric":"some.metric.name", "value":100.0, "tag":"any.tag", "host":"any.host", "type":"gauge"}' | fluent-cat datadog.metric
32
+ echo '{"metric":"some.metric.name", "value":100.0, "tag":"any.tag", "host":"any.host", "type":"gauge", "device":"my_device"}' | fluent-cat datadog.metric
29
33
  ```
30
34
 
31
35
  ## Contributing
@@ -1,12 +1,12 @@
1
1
  # coding: utf-8
2
2
  Gem::Specification.new do |spec|
3
3
  spec.name = 'fluent-plugin-dd'
4
- spec.version = '0.1.5'
4
+ spec.version = '0.1.6'
5
5
  spec.authors = ['Genki Sugawara']
6
6
  spec.email = ['sugawara@cookpad.com']
7
7
  spec.description = %q{Output plugin for Datadog}
8
8
  spec.summary = %q{Output plugin for Datadog}
9
- spec.homepage = 'https://bitbucket.org/winebarrel/fluent-plugin-dd'
9
+ spec.homepage = 'https://github.com/winebarrel/fluent-plugin-dd'
10
10
  spec.license = 'MIT'
11
11
 
12
12
  spec.files = `git ls-files`.split($/)
@@ -15,8 +15,8 @@ Gem::Specification.new do |spec|
15
15
  spec.require_paths = ['lib']
16
16
 
17
17
  spec.add_dependency 'fluentd'
18
- spec.add_dependency 'dogapi'
19
- spec.add_development_dependency 'bundler', '~> 1.3'
18
+ spec.add_dependency 'dogapi', '>= 1.10.0'
19
+ spec.add_development_dependency 'bundler'
20
20
  spec.add_development_dependency 'rake'
21
- spec.add_development_dependency 'rspec', '>= 2.11.0'
21
+ spec.add_development_dependency 'rspec', '>= 3.0.0'
22
22
  end
@@ -6,7 +6,11 @@ class Fluent::DdOutput < Fluent::BufferedOutput
6
6
  end
7
7
 
8
8
  config_param :dd_api_key, :string
9
+ config_param :dd_app_key, :string, :default => nil
9
10
  config_param :host, :string, :default => nil
11
+ config_param :device, :string, :default => nil
12
+ config_param :silent, :bool, :default => true
13
+ config_param :timeout, :integer, :default => nil
10
14
  config_param :use_fluentd_tag_for_datadog_tag, :bool, :default => false
11
15
  config_param :emit_in_background, :bool, :default => false
12
16
  config_param :concurrency, :integer, :default => nil
@@ -65,7 +69,7 @@ class Fluent::DdOutput < Fluent::BufferedOutput
65
69
  @host = Socket.gethostname if @host.empty?
66
70
  end
67
71
 
68
- @dog = Dogapi::Client.new(@dd_api_key, nil, @host)
72
+ @dog = Dogapi::Client.new(@dd_api_key, @dd_app_key, @host, @device, @silent, @timeout)
69
73
  end
70
74
 
71
75
  def format(tag, time, record)
@@ -106,9 +110,9 @@ class Fluent::DdOutput < Fluent::BufferedOutput
106
110
  dd_tag = tag
107
111
  end
108
112
 
109
- [dd_tag] + record.values_at('metric', 'host', 'type')
113
+ [dd_tag] + record.values_at('metric', 'host', 'type', 'device')
110
114
  }.map {|i, records|
111
- tag, metric, host, type = i
115
+ tag, metric, host, type, device = i
112
116
 
113
117
  points = records.map do |tag, time, record|
114
118
  time = Time.at(time)
@@ -120,6 +124,7 @@ class Fluent::DdOutput < Fluent::BufferedOutput
120
124
  options[:tags] = tag.split(',').map {|i| i.strip } if tag
121
125
  options[:host] = host if host
122
126
  options[:type] = type if type
127
+ options[:device] = device if device
123
128
 
124
129
  [metric, points, options]
125
130
  }
data/spec/out_dd_spec.rb CHANGED
@@ -3,14 +3,39 @@ describe Fluent::DdOutput do
3
3
  Time.parse('2014-02-08 04:14:15 UTC').to_i
4
4
  }
5
5
 
6
+ it 'should load config' do
7
+ driver = Fluent::Test::OutputTestDriver.new(Fluent::DdOutput, 'test.default')
8
+
9
+ driver.configure(<<-EOS)
10
+ type dd
11
+ dd_api_key API_KEY
12
+ dd_app_key APP_KEY
13
+ host my_host.example.com
14
+ device my_device
15
+ silent false
16
+ timeout 5
17
+ use_fluentd_tag_for_datadog_tag true
18
+ emit_in_background true
19
+ EOS
20
+
21
+ expect(driver.instance.dd_api_key).to eq 'API_KEY'
22
+ expect(driver.instance.dd_app_key).to eq 'APP_KEY'
23
+ expect(driver.instance.host).to eq 'my_host.example.com'
24
+ expect(driver.instance.device).to eq 'my_device'
25
+ expect(driver.instance.silent).to eq false
26
+ expect(driver.instance.timeout).to eq 5
27
+ expect(driver.instance.use_fluentd_tag_for_datadog_tag).to eq true
28
+ expect(driver.instance.emit_in_background).to eq true
29
+ end
30
+
6
31
  it 'should receive an API key' do
7
- Dogapi::Client.should_receive(:new).with("test_dd_api_key", nil, "test_host")
32
+ expect(Dogapi::Client).to receive(:new).with("test_dd_api_key", nil, "test_host", nil, true, nil)
8
33
  run_driver {|d, dog| }
9
34
  end
10
35
 
11
36
  it 'should be called emit_points' do
12
37
  run_driver do |d, dog|
13
- dog.should_receive(:emit_points).with(
38
+ expect(dog).to receive(:emit_points).with(
14
39
  "some.metric.name",
15
40
  [[Time.parse("2014-02-08 04:14:15 UTC"), 50.0],
16
41
  [Time.parse("2014-02-08 04:14:15 UTC"), 100.0]],
@@ -33,7 +58,7 @@ describe Fluent::DdOutput do
33
58
 
34
59
  it 'should be called emit_points in the background' do
35
60
  run_driver(:emit_in_background => true) do |d, dog|
36
- dog.should_receive(:emit_points).with(
61
+ expect(dog).to receive(:emit_points).with(
37
62
  "some.metric.name",
38
63
  [[Time.parse("2014-02-08 04:14:15 UTC"), 50.0],
39
64
  [Time.parse("2014-02-08 04:14:15 UTC"), 100.0]],
@@ -50,12 +75,12 @@ describe Fluent::DdOutput do
50
75
  :emit_in_background => true,
51
76
  :concurrency => 2,
52
77
  ) do |d, dog|
53
- dog.should_receive(:emit_points).with(
78
+ expect(dog).to receive(:emit_points).with(
54
79
  "some.metric.name.1",
55
80
  [[Time.parse("2014-02-08 04:14:15 UTC"), 50.0]],
56
81
  {}
57
82
  )
58
- dog.should_receive(:emit_points).with(
83
+ expect(dog).to receive(:emit_points).with(
59
84
  "some.metric.name.2",
60
85
  [[Time.parse("2014-02-08 04:14:15 UTC"), 100.0]],
61
86
  {}
@@ -72,7 +97,7 @@ describe Fluent::DdOutput do
72
97
 
73
98
  it 'should be called emit_points with tag' do
74
99
  run_driver(:use_fluentd_tag_for_datadog_tag => true) do |d, dog|
75
- dog.should_receive(:emit_points).with(
100
+ expect(dog).to receive(:emit_points).with(
76
101
  "some.metric.name",
77
102
  [[Time.parse("2014-02-08 04:14:15 UTC"), 50.0],
78
103
  [Time.parse("2014-02-08 04:14:15 UTC"), 100.0]],
@@ -86,21 +111,21 @@ describe Fluent::DdOutput do
86
111
 
87
112
  it 'should be called emit_points for each tag' do
88
113
  run_driver(:use_fluentd_tag_for_datadog_tag => true) do |d, dog|
89
- dog.should_receive(:emit_points).with(
114
+ expect(dog).to receive(:emit_points).with(
90
115
  "some.metric.name",
91
116
  [[Time.parse("2014-02-08 04:14:15 UTC"), 50.0],
92
117
  [Time.parse("2014-02-08 04:14:15 UTC"), 100.0]],
93
118
  {:tags=>["test.1"]}
94
119
  )
95
120
 
96
- dog.should_receive(:emit_points).with(
121
+ expect(dog).to receive(:emit_points).with(
97
122
  "some.metric.name",
98
123
  [[Time.parse("2014-02-08 04:14:15 UTC"), 150.0],
99
124
  [Time.parse("2014-02-08 04:14:15 UTC"), 200.0]],
100
125
  {:tags=>["test.2"]}
101
126
  )
102
127
 
103
- dog.should_receive(:emit_points).with(
128
+ expect(dog).to receive(:emit_points).with(
104
129
  "some.metric.name",
105
130
  [[Time.parse("2014-02-08 04:14:15 UTC"), 250.0],
106
131
  [Time.parse("2014-02-08 04:14:15 UTC"), 300.0]],
@@ -123,21 +148,21 @@ describe Fluent::DdOutput do
123
148
 
124
149
  it 'should be called emit_points for each tag (tag is included in the record)' do
125
150
  run_driver do |d, dog|
126
- dog.should_receive(:emit_points).with(
151
+ expect(dog).to receive(:emit_points).with(
127
152
  "some.metric.name",
128
153
  [[Time.parse("2014-02-08 04:14:15 UTC"), 50.0],
129
154
  [Time.parse("2014-02-08 04:14:15 UTC"), 100.0]],
130
155
  {:tags=>["test.11"]}
131
156
  )
132
157
 
133
- dog.should_receive(:emit_points).with(
158
+ expect(dog).to receive(:emit_points).with(
134
159
  "some.metric.name",
135
160
  [[Time.parse("2014-02-08 04:14:15 UTC"), 150.0],
136
161
  [Time.parse("2014-02-08 04:14:15 UTC"), 200.0]],
137
162
  {:tags=>["test.21"]}
138
163
  )
139
164
 
140
- dog.should_receive(:emit_points).with(
165
+ expect(dog).to receive(:emit_points).with(
141
166
  "some.metric.name",
142
167
  [[Time.parse("2014-02-08 04:14:15 UTC"), 250.0],
143
168
  [Time.parse("2014-02-08 04:14:15 UTC"), 300.0]],
@@ -157,21 +182,21 @@ describe Fluent::DdOutput do
157
182
 
158
183
  it 'should be called emit_points with multiple tags' do
159
184
  run_driver do |d, dog|
160
- dog.should_receive(:emit_points).with(
185
+ expect(dog).to receive(:emit_points).with(
161
186
  "some.metric.name",
162
187
  [[Time.parse("2014-02-08 04:14:15 UTC"), 50.0],
163
188
  [Time.parse("2014-02-08 04:14:15 UTC"), 100.0]],
164
189
  {:tags=>["test.12","test.13"]}
165
190
  )
166
191
 
167
- dog.should_receive(:emit_points).with(
192
+ expect(dog).to receive(:emit_points).with(
168
193
  "some.metric.name",
169
194
  [[Time.parse("2014-02-08 04:14:15 UTC"), 150.0],
170
195
  [Time.parse("2014-02-08 04:14:15 UTC"), 200.0]],
171
196
  {:tags=>["test.22","test.23"]}
172
197
  )
173
198
 
174
- dog.should_receive(:emit_points).with(
199
+ expect(dog).to receive(:emit_points).with(
175
200
  "some.metric.name",
176
201
  [[Time.parse("2014-02-08 04:14:15 UTC"), 250.0],
177
202
  [Time.parse("2014-02-08 04:14:15 UTC"), 300.0]],
@@ -191,21 +216,21 @@ describe Fluent::DdOutput do
191
216
 
192
217
  it 'should be called emit_points for each host' do
193
218
  run_driver do |d, dog|
194
- dog.should_receive(:emit_points).with(
219
+ expect(dog).to receive(:emit_points).with(
195
220
  "some.metric.name",
196
221
  [[Time.parse("2014-02-08 04:14:15 UTC"), 50.0],
197
222
  [Time.parse("2014-02-08 04:14:15 UTC"), 100.0]],
198
223
  {:host=>"www1.example.com"}
199
224
  )
200
225
 
201
- dog.should_receive(:emit_points).with(
226
+ expect(dog).to receive(:emit_points).with(
202
227
  "some.metric.name",
203
228
  [[Time.parse("2014-02-08 04:14:15 UTC"), 150.0],
204
229
  [Time.parse("2014-02-08 04:14:15 UTC"), 200.0]],
205
230
  {:host=>"www2.example.com"}
206
231
  )
207
232
 
208
- dog.should_receive(:emit_points).with(
233
+ expect(dog).to receive(:emit_points).with(
209
234
  "some.metric.name",
210
235
  [[Time.parse("2014-02-08 04:14:15 UTC"), 250.0],
211
236
  [Time.parse("2014-02-08 04:14:15 UTC"), 300.0]],
@@ -221,16 +246,48 @@ describe Fluent::DdOutput do
221
246
  end
222
247
  end
223
248
 
249
+ it 'should be called emit_points for each device' do
250
+ run_driver do |d, dog|
251
+ expect(dog).to receive(:emit_points).with(
252
+ "some.metric.name",
253
+ [[Time.parse("2014-02-08 04:14:15 UTC"), 50.0],
254
+ [Time.parse("2014-02-08 04:14:15 UTC"), 100.0]],
255
+ {:device=>"device1"}
256
+ )
257
+
258
+ expect(dog).to receive(:emit_points).with(
259
+ "some.metric.name",
260
+ [[Time.parse("2014-02-08 04:14:15 UTC"), 150.0],
261
+ [Time.parse("2014-02-08 04:14:15 UTC"), 200.0]],
262
+ {:device=>"device2"}
263
+ )
264
+
265
+ expect(dog).to receive(:emit_points).with(
266
+ "some.metric.name",
267
+ [[Time.parse("2014-02-08 04:14:15 UTC"), 250.0],
268
+ [Time.parse("2014-02-08 04:14:15 UTC"), 300.0]],
269
+ {:device=>"device3"}
270
+ )
271
+
272
+ d.emit({"metric" => "some.metric.name", "value" => 50.0, "device" => "device1"}, time)
273
+ d.emit({"metric" => "some.metric.name", "value" => 100.0, "device" => "device1"}, time)
274
+ d.emit({"metric" => "some.metric.name", "value" => 150.0, "device" => "device2"}, time)
275
+ d.emit({"metric" => "some.metric.name", "value" => 200.0, "device" => "device2"}, time)
276
+ d.emit({"metric" => "some.metric.name", "value" => 250.0, "device" => "device3"}, time)
277
+ d.emit({"metric" => "some.metric.name", "value" => 300.0, "device" => "device3"}, time)
278
+ end
279
+ end
280
+
224
281
  it 'should be called emit_points for each type' do
225
282
  run_driver do |d, dog|
226
- dog.should_receive(:emit_points).with(
283
+ expect(dog).to receive(:emit_points).with(
227
284
  "some.metric.name",
228
285
  [[Time.parse("2014-02-08 04:14:15 UTC"), 50.0],
229
286
  [Time.parse("2014-02-08 04:14:15 UTC"), 100.0]],
230
287
  {:type=>"gauge"}
231
288
  )
232
289
 
233
- dog.should_receive(:emit_points).with(
290
+ expect(dog).to receive(:emit_points).with(
234
291
  "some.metric.name",
235
292
  [[Time.parse("2014-02-08 04:14:15 UTC"), 150.0],
236
293
  [Time.parse("2014-02-08 04:14:15 UTC"), 200.0]],
@@ -246,7 +303,7 @@ describe Fluent::DdOutput do
246
303
 
247
304
  it 'should be skipped if `metric` key does not exists' do
248
305
  run_driver do |d, dog|
249
- dog.should_receive(:emit_points).with(
306
+ expect(dog).to receive(:emit_points).with(
250
307
  "some.metric.name",
251
308
  [[Time.parse("2014-02-08 04:14:15 UTC"), 50.0],
252
309
  [Time.parse("2014-02-08 04:14:15 UTC"), 100.0]],
@@ -254,9 +311,9 @@ describe Fluent::DdOutput do
254
311
  )
255
312
 
256
313
  log = d.instance.log
257
- log.should_receive(:warn)
314
+ expect(log).to receive(:warn)
258
315
  .with('`metric` key does not exist: ["test.default", 1391832855, {"no metric"=>"some.metric.name", "value"=>51.0}]')
259
- log.should_receive(:warn)
316
+ expect(log).to receive(:warn)
260
317
  .with('`metric` key does not exist: ["test.default", 1391832855, {"no metric"=>"some.metric.name", "value"=>101.0}]')
261
318
 
262
319
  d.emit({"no metric" => "some.metric.name", "value" => 51.0}, time)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-dd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genki Sugawara
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-02 00:00:00.000000000 Z
11
+ date: 2015-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -30,28 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - '>='
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 1.10.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '>='
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 1.10.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
- version: '1.3'
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
- version: '1.3'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - '>='
74
74
  - !ruby/object:Gem::Version
75
- version: 2.11.0
75
+ version: 3.0.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - '>='
81
81
  - !ruby/object:Gem::Version
82
- version: 2.11.0
82
+ version: 3.0.0
83
83
  description: Output plugin for Datadog
84
84
  email:
85
85
  - sugawara@cookpad.com
@@ -89,6 +89,7 @@ extra_rdoc_files: []
89
89
  files:
90
90
  - .gitignore
91
91
  - .rspec
92
+ - .travis.yml
92
93
  - Gemfile
93
94
  - LICENSE.txt
94
95
  - README.md
@@ -97,7 +98,7 @@ files:
97
98
  - lib/fluent/plugin/out_dd.rb
98
99
  - spec/out_dd_spec.rb
99
100
  - spec/spec_helper.rb
100
- homepage: https://bitbucket.org/winebarrel/fluent-plugin-dd
101
+ homepage: https://github.com/winebarrel/fluent-plugin-dd
101
102
  licenses:
102
103
  - MIT
103
104
  metadata: {}
@@ -124,4 +125,3 @@ summary: Output plugin for Datadog
124
125
  test_files:
125
126
  - spec/out_dd_spec.rb
126
127
  - spec/spec_helper.rb
127
- has_rdoc: