fluent-plugin-histogram 0.2.2 → 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 +8 -8
- data/fluent-plugin-histogram.gemspec +1 -1
- data/lib/fluent/plugin/out_histogram.rb +12 -5
- data/test/plugin/test_out_histogram.rb +29 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MjE3MzNkNjEwZDczYzBhMDk0NmIxMWEwNDk2ZTliOWNhYzRhOGJjNw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YzEyYTFkNmQxNWY1MjZhMzNhZTU1NjczMTNjMzIzMmE0M2QyZTk5OA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MWUzNzgyMDM3NGRiNGZiODlkOWEzMjhiNzg0NzQ2NzJiN2E0Mzc5MDA2MGQz
|
10
|
+
NmU2M2ZhNTg0MGJjYzNkN2Q4NzdjZTU4N2JiM2EyNGJhYTJiMDdjZDU2MDBj
|
11
|
+
YTdjMjYxMDE2ZDg0Mjg3NzMyZTFiYjdjOTMxMjRhYTFjYTMzMWU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NGQyMmRkNzQxZWVmZjc4MThkNTM1YmZiYmVlZjA1YzZmODBjZDg4NWYyODlj
|
14
|
+
MmYzNTZiNGI3Njk1MTExYjc4YmIwNDYxMGJlYzQ4ZGY2MGIzMmE1ZTFhYTNk
|
15
|
+
NWNhODIwODZmNjI2NjVjNjdmMmRkYWQ2MjY0YWY5NjgyN2U3YmE=
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |gem|
|
4
4
|
gem.name = "fluent-plugin-histogram"
|
5
|
-
gem.version = "0.2.
|
5
|
+
gem.version = "0.2.4"
|
6
6
|
gem.authors = ["Yusuke SHIMIZU"]
|
7
7
|
gem.email = "a.ryuklnm@gmail.com"
|
8
8
|
gem.description = "Combine inputs data and make histogram which helps to detect a hotspot."
|
@@ -175,11 +175,18 @@ module Fluent
|
|
175
175
|
output = {}
|
176
176
|
flushed.each do |tag, hist|
|
177
177
|
output[tag] = {}
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
178
|
+
act_hist = hist.dup.select!{|v| v > 0}
|
179
|
+
if act_hist.size == 0 # equal to zero_hist
|
180
|
+
sum = 0
|
181
|
+
avg = 0
|
182
|
+
sd = 0
|
183
|
+
else
|
184
|
+
sum = act_hist.inject(:+)
|
185
|
+
avg = sum / act_hist.size
|
186
|
+
sd = act_hist.instance_eval do
|
187
|
+
sigmas = map { |n| (avg - n)**2 }
|
188
|
+
Math.sqrt(sigmas.inject(:+) / size)
|
189
|
+
end
|
183
190
|
end
|
184
191
|
output[tag][:hist] = hist if @out_include_hist
|
185
192
|
output[tag][:sum] = @disable_revalue ? sum : sum / @revalue
|
@@ -53,12 +53,13 @@ class HistogramOutputTest < Test::Unit::TestCase
|
|
53
53
|
hist[id] += 1
|
54
54
|
end
|
55
55
|
|
56
|
-
|
56
|
+
act_hist = hist.dup.select{|v| v > 0}
|
57
|
+
sd = act_hist.instance_eval do
|
57
58
|
avg = inject(:+) / size
|
58
59
|
sigmas = map { |n| (avg - n)**2 }
|
59
60
|
Math.sqrt(sigmas.inject(:+) / size)
|
60
61
|
end
|
61
|
-
assert_equal({"test.input" => {:hist => hist, :sum => 6, :avg => 6/
|
62
|
+
assert_equal({"test.input" => {:hist => hist, :sum => 6, :avg => 6/act_hist.size, :sd=>sd.to_i}},
|
62
63
|
f.instance.flush)
|
63
64
|
end
|
64
65
|
|
@@ -98,12 +99,13 @@ class HistogramOutputTest < Test::Unit::TestCase
|
|
98
99
|
hist[(id - alpha) % bin_num] += 1
|
99
100
|
end
|
100
101
|
|
101
|
-
|
102
|
+
act_hist = hist.select{|v| v > 0}
|
103
|
+
sd = act_hist.instance_eval do
|
102
104
|
avg = inject(:+) / size
|
103
105
|
sigmas = map { |n| (avg - n)**2 }
|
104
106
|
Math.sqrt(sigmas.inject(:+) / size)
|
105
107
|
end
|
106
|
-
assert_equal({"test.input" => {:hist => hist, :sum => 6, :avg => 6/
|
108
|
+
assert_equal({"test.input" => {:hist => hist, :sum => 6, :avg => 6/act_hist.size, :sd=>sd.to_i}},
|
107
109
|
f.instance.flush)
|
108
110
|
end
|
109
111
|
|
@@ -156,8 +158,9 @@ class HistogramOutputTest < Test::Unit::TestCase
|
|
156
158
|
f.instance.increment("test.input", i.to_s)
|
157
159
|
end
|
158
160
|
flushed = f.instance.flush
|
161
|
+
act_hist = flushed["test.input"][:hist].select{|v| v > 0}
|
159
162
|
assert_equal(1000, flushed["test.input"][:sum])
|
160
|
-
assert_equal(1000/
|
163
|
+
assert_equal(1000/act_hist.size, flushed["test.input"][:avg])
|
161
164
|
end
|
162
165
|
|
163
166
|
def test_emit
|
@@ -171,8 +174,9 @@ class HistogramOutputTest < Test::Unit::TestCase
|
|
171
174
|
end
|
172
175
|
end
|
173
176
|
flushed = f.instance.flush
|
177
|
+
act_hist = flushed["test"][:hist].select{|v| v > 0}
|
174
178
|
assert_equal(300, flushed["test"][:sum])
|
175
|
-
assert_equal(300/
|
179
|
+
assert_equal(300/act_hist.size, flushed["test"][:avg])
|
176
180
|
end
|
177
181
|
|
178
182
|
def test_some_hist_exist_case_tagging_with_emit
|
@@ -302,14 +306,31 @@ bias:#{flushed_bias["histo.localhost"]}")
|
|
302
306
|
id = "c"[0..9].codepoints.collect{|cp| cp}.join().to_i % bin_num
|
303
307
|
hist[id] += 3
|
304
308
|
|
305
|
-
|
309
|
+
act_hist = hist.dup.select{|v| v > 0}
|
310
|
+
sd = act_hist.instance_eval do
|
306
311
|
avg = inject(:+) / size
|
307
312
|
sigmas = map { |n| (avg - n)**2 }
|
308
313
|
Math.sqrt(sigmas.inject(:+) / size)
|
309
314
|
end
|
310
315
|
flushed = f.instance.flush
|
311
|
-
assert_equal({"test.input" => {:hist => hist, :sum => 6, :avg => 6/
|
316
|
+
assert_equal({"test.input" => {:hist => hist, :sum => 6, :avg => 6/act_hist.size, :sd=>sd.to_i}}, flushed)
|
312
317
|
end
|
313
318
|
|
319
|
+
def test_output_zero_length_hist
|
320
|
+
bin_num = 5
|
321
|
+
f = create_driver(%[ bin_num #{bin_num} ])
|
322
|
+
flushed = f.instance.flush
|
323
|
+
assert_equal({}, flushed)
|
324
|
+
|
325
|
+
f.run do
|
326
|
+
f.emit({"keys" => "a"})
|
327
|
+
end
|
328
|
+
f.instance.flush # flush
|
329
|
+
flushed = f.instance.flush
|
330
|
+
assert_equal([0]*5, flushed["test"][:hist])
|
331
|
+
assert_equal(0, flushed["test"][:sum])
|
332
|
+
assert_equal(0, flushed["test"][:avg])
|
333
|
+
assert_equal(0, flushed["test"][:sd])
|
334
|
+
end
|
314
335
|
|
315
336
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-histogram
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yusuke SHIMIZU
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|