fluent-plugin-numeric-monitor 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  Gem::Specification.new do |gem|
3
3
  gem.name = "fluent-plugin-numeric-monitor"
4
- gem.version = "0.1.1"
4
+ gem.version = "0.1.2"
5
5
  gem.authors = ["TAGOMORI Satoshi"]
6
6
  gem.email = ["tagomoris@gmail.com"]
7
7
  gem.description = %q{Fluentd plugin to calculate min/max/avg/Xpercentile values, and emit these data as message}
@@ -195,7 +195,6 @@ class Fluent::NumericMonitorOutput < Fluent::Output
195
195
  next if value.nil?
196
196
 
197
197
  value = value.to_f
198
-
199
198
  if min.nil? or min > value
200
199
  min = value
201
200
  end
@@ -209,7 +208,7 @@ class Fluent::NumericMonitorOutput < Fluent::Output
209
208
  sample.push(value)
210
209
  end
211
210
  end
212
- if sample.size > @samples_limit
211
+ if @percentiles && sample.size > @samples_limit
213
212
  (sample.size - @samples_limit / 2).to_i.times do
214
213
  sample.delete_at(rand(sample.size))
215
214
  end
@@ -64,4 +64,22 @@ class NumericMonitorOutputTest < Test::Unit::TestCase
64
64
  assert_equal 8, r1['tag1_percentile_90']
65
65
  assert_equal 100, r1['tag1_num']
66
66
  end
67
+
68
+ def test_without_percentiles
69
+ d = create_driver(%[
70
+ unit minute
71
+ tag testmonitor
72
+ monitor_key x1
73
+ ], 'test')
74
+ d.run do
75
+ d.emit({'x1' => 1})
76
+ d.emit({'x1' => 2})
77
+ d.emit({'x1' => 3})
78
+ end
79
+ r = d.instance.flush
80
+ assert_equal 1, r['test_min']
81
+ assert_equal 3, r['test_max']
82
+ assert_equal 2, r['test_avg']
83
+ assert_equal 3, r['test_num']
84
+ end
67
85
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-numeric-monitor
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:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-07 00:00:00.000000000 Z
12
+ date: 2012-12-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fluentd