fluent-plugin-growthforecast 0.2.3 → 0.2.4

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: ce309fd9162a5d30d1a24cfaed6c72feb607ecbe
4
- data.tar.gz: 649824e492f0132967303c1d0f7400c1bdcab98c
3
+ metadata.gz: 865e153a44d5b24396037e62f80b811d3e8289a1
4
+ data.tar.gz: 2482017862d4aa533da0f493c1447e5a7fefac73
5
5
  SHA512:
6
- metadata.gz: 2301b6ce097f7ff46d55a0e972574a5d8b0ba57f2555be7d575bc936b40cfa8f2c394e3d6c2196c3dc77c97339a3cf90c5dbbe8f60fc1d959ed52e393c6e9f72
7
- data.tar.gz: 16de04d7a45a0810db0da6de6bb521082899cf488808baa60aa8cd1af2d20ba3693c57191b2bfc77170b82572d4d5357b6991a93a0a07768b09a32e5999bcdf6
6
+ metadata.gz: c4be0e7f1b76d4edfc035b01f1d50aceef0a79890a715cd034b7a4bfef9497494f97db137a6795dd24eee73aefdf275077c714d4637322aa9f8f21893c5de8ea
7
+ data.tar.gz: 6cadc77b0cb9c0611b106b0aa27d74a9d45974394bb269c0d1afa3cd7651b22e7caa8abbbd234403ba5060ef6c98dc65f999d4f5eb1a9d2ff600cd58d4085002
data/README.md CHANGED
@@ -168,6 +168,12 @@ Version v0.2.0 or later, this plugin uses HTTP connection keep-alive for a batch
168
168
 
169
169
  The password for authentication.
170
170
 
171
+ * enable\_float\_number
172
+
173
+ Post a floating number rather than an interger number. Default is false.
174
+
175
+ NOTE: You need to run your GrowthForecast with `--enable-float-number` option, supported by GrowthForecast v0.70 or later.
176
+
171
177
  ## TODO
172
178
 
173
179
  * patches welcome!
@@ -2,12 +2,13 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = "fluent-plugin-growthforecast"
5
- gem.version = "0.2.3"
5
+ gem.version = "0.2.4"
6
6
  gem.authors = ["TAGOMORI Satoshi"]
7
7
  gem.email = ["tagomoris@gmail.com"]
8
8
  gem.summary = %q{Fluentd output plugin to post numbers to GrowthForecast (by kazeburo)}
9
9
  gem.description = %q{For GrowthForecast, see http://kazeburo.github.com/GrowthForecast/}
10
10
  gem.homepage = "https://github.com/tagomoris/fluent-plugin-growthforecast"
11
+ gem.license = "APLv2"
11
12
 
12
13
  gem.files = `git ls-files`.split($\)
13
14
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -29,6 +29,7 @@ class Fluent::GrowthForecastOutput < Fluent::Output
29
29
  config_param :timeout, :integer, :default => nil # default 60secs
30
30
  config_param :retry, :bool, :default => true
31
31
  config_param :keepalive, :bool, :default => true
32
+ config_param :enable_float_number, :bool, :default => false
32
33
 
33
34
  config_param :authentication, :string, :default => nil # nil or 'none' or 'basic'
34
35
  config_param :username, :string, :default => ''
@@ -132,7 +133,7 @@ class Fluent::GrowthForecastOutput < Fluent::Output
132
133
  begin
133
134
  post_events(events) if events.size > 0
134
135
  rescue => e
135
- $log.warn "HTTP POST Error occures to growthforecast server", :error_class => e.class, :error => e.message
136
+ $log.warn "HTTP POST in background Error occures to growthforecast server", :error_class => e.class, :error => e.message
136
137
  end
137
138
  end
138
139
  end
@@ -185,7 +186,8 @@ class Fluent::GrowthForecastOutput < Fluent::Output
185
186
  if @keepalive
186
187
  req['Connection'] = 'Keep-Alive'
187
188
  end
188
- req.set_form_data({'number' => value.to_i, 'mode' => @mode.to_s})
189
+ value = @enable_float_number ? value.to_f : value.to_i
190
+ req.set_form_data({'number' => value, 'mode' => @mode.to_s})
189
191
  req
190
192
  end
191
193
 
@@ -199,7 +201,7 @@ class Fluent::GrowthForecastOutput < Fluent::Output
199
201
  res = http.start {|http| http.request(req) }
200
202
  rescue IOError, EOFError, SystemCallError
201
203
  # server didn't respond
202
- $log.warn "Net::HTTP.post_form raises exception: #{$!.class}, '#{$!.message}'"
204
+ $log.warn "net/http POST raises exception: #{$!.class}, '#{$!.message}'"
203
205
  end
204
206
  unless res and res.is_a?(Net::HTTPSuccess)
205
207
  $log.warn "failed to post to growthforecast: #{url}, number: #{value}, code: #{res && res.code}"
@@ -224,7 +226,7 @@ class Fluent::GrowthForecastOutput < Fluent::Output
224
226
  end
225
227
  end
226
228
  rescue IOError, EOFError, SystemCallError
227
- $log.warn "Net::HTTP.post_form raises exception: #{$!.class}, '#{$!.message}'"
229
+ $log.warn "net/http keepalive POST raises exception: #{$!.class}, '#{$!.message}'"
228
230
  end
229
231
  end
230
232
 
@@ -103,6 +103,15 @@ class GrowthForecastOutputTest < Test::Unit::TestCase
103
103
  tag_for name_prefix
104
104
  ]
105
105
 
106
+ CONFIG_ENABLE_FLOAT_NUMBER = %[
107
+ gfapi_url http://127.0.0.1:5125/api/
108
+ service service
109
+ section metrics
110
+ name_keys field1,field2,otherfield
111
+ tag_for name_prefix
112
+ enable_float_number true
113
+ ]
114
+
106
115
  def create_driver(conf=CONFIG1, tag='test.metrics')
107
116
  Fluent::Test::OutputTestDriver.new(Fluent::GrowthForecastOutput, tag).configure(conf)
108
117
  end
@@ -472,12 +481,47 @@ class GrowthForecastOutputTest < Test::Unit::TestCase
472
481
  assert_equal 'test.metrics_othergraph', v3rd[:name]
473
482
  end
474
483
 
484
+ # CONFIG_NON_KEEPALIVE = %[
485
+ # gfapi_url http://127.0.0.1:5125/api/
486
+ # service service
487
+ # section metrics
488
+ # name_keys field1,field2,otherfield
489
+ # tag_for name_prefix
490
+ # enable_float_number true
491
+ # ]
492
+ def test_enable_float_number
493
+ @enable_float_number = true # enable float number of dummy server
494
+
495
+ d = create_driver(CONFIG_ENABLE_FLOAT_NUMBER, 'test.metrics')
496
+ d.emit({ 'field1' => 50.5, 'field2' => -20.1, 'field3' => 10, 'otherfield' => 1 })
497
+ d.run
498
+
499
+ assert_equal 3, @posted.size
500
+ v1st = @posted[0]
501
+ v2nd = @posted[1]
502
+ v3rd = @posted[2]
503
+
504
+ assert_equal 50.5, v1st[:data][:number]
505
+ assert_equal 'gauge', v1st[:data][:mode]
506
+ assert_nil v1st[:auth]
507
+ assert_equal 'service', v1st[:service]
508
+ assert_equal 'metrics', v1st[:section]
509
+ assert_equal 'test.metrics_field1', v1st[:name]
510
+
511
+ assert_equal -20.1, v2nd[:data][:number]
512
+ assert_equal 'test.metrics_field2', v2nd[:name]
513
+
514
+ assert_equal 1, v3rd[:data][:number]
515
+ assert_equal 'test.metrics_otherfield', v3rd[:name]
516
+ end
517
+
475
518
  # setup / teardown for servers
476
519
  def setup
477
520
  Fluent::Test.setup
478
521
  @posted = []
479
522
  @prohibited = 0
480
523
  @auth = false
524
+ @enable_float_number = false
481
525
  @dummy_server_thread = Thread.new do
482
526
  srv = if ENV['VERBOSE']
483
527
  WEBrick::HTTPServer.new({:BindAddress => '127.0.0.1', :Port => GF_TEST_LISTEN_PORT})
@@ -508,12 +552,13 @@ class GrowthForecastOutputTest < Test::Unit::TestCase
508
552
  graph_name = $3
509
553
  post_param = Hash[*(req.body.split('&').map{|kv|kv.split('=')}.flatten)]
510
554
 
555
+ number = @enable_float_number ? post_param['number'].to_f : post_param['number'].to_i
511
556
  @posted.push({
512
557
  :service => service,
513
558
  :section => section,
514
559
  :name => graph_name,
515
560
  :auth => nil,
516
- :data => { :number => post_param['number'].to_i, :mode => post_param['mode'] },
561
+ :data => { :number => number, :mode => post_param['mode'] },
517
562
  })
518
563
 
519
564
  res.status = 200
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-growthforecast
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - TAGOMORI Satoshi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-22 00:00:00.000000000 Z
11
+ date: 2013-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -86,7 +86,8 @@ files:
86
86
  - test/helper.rb
87
87
  - test/plugin/test_out_growthforecast.rb
88
88
  homepage: https://github.com/tagomoris/fluent-plugin-growthforecast
89
- licenses: []
89
+ licenses:
90
+ - APLv2
90
91
  metadata: {}
91
92
  post_install_message:
92
93
  rdoc_options: []
@@ -111,3 +112,4 @@ summary: Fluentd output plugin to post numbers to GrowthForecast (by kazeburo)
111
112
  test_files:
112
113
  - test/helper.rb
113
114
  - test/plugin/test_out_growthforecast.rb
115
+ has_rdoc: