fluent-plugin-histogram 0.1.4 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/fluent-plugin-histogram.gemspec +1 -1
- data/lib/fluent/plugin/out_histogram.rb +3 -1
- data/test/plugin/test_out_histogram.rb +17 -11
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MTUxMjBkOGI3NTZmZGY2MzY2ZTg5MzcwODZlYjBkYjVmYmEzZjE3Mw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Mjc4MTFkYzMyODIwZjE5NDJjNWI2ZjFiYjk0NmViNGE3ODU1ZjNmYQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MzQwYTFiYjlhMTMzYzdlMzdkNWNmYTdhZGU2NWZkOGIwNGI2YzdkZDk2OTZj
|
10
|
+
NzlhNGQzYzllZDQ1MjZjMzliMzVkM2Q2ZjFhNDkxZDQxYmJiMWU2OWU3YmEy
|
11
|
+
MGVmNDIwYmIwNjUzNzI2MjI4Y2NiMGNlZWZiMWMxNGMyYmI3MGY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzQ1ZTNjMTFjNGE4ODRiNmUyZGM0MjI1ZTRmYTZhMzJhMmExNDIwY2VjZDMy
|
14
|
+
OGMyZTYwMmExN2UxZTBjOGIwNzgxYzU3ZWJiZjQxYWRiZTc1Yzk4MTViMjNi
|
15
|
+
MTNmNmI4ZThkMzg5YTdjZjQ2NWEzZjcyNmVlZmJjNjkyOTVkYTU=
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |gem|
|
4
4
|
gem.name = "fluent-plugin-histogram"
|
5
|
-
gem.version = "0.
|
5
|
+
gem.version = "0.2.0"
|
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."
|
@@ -100,7 +100,9 @@ module Fluent
|
|
100
100
|
|
101
101
|
def increment(tag, key)
|
102
102
|
@hists[tag] ||= @zero_hist.dup
|
103
|
-
|
103
|
+
|
104
|
+
# id = key.hash % @bin_num
|
105
|
+
id = key[0..9].codepoints.collect{|cp| cp}.join().to_i % @bin_num # attention to long key(length > 10)
|
104
106
|
@mutex.synchronize {
|
105
107
|
(0..@alpha).each do |alpha|
|
106
108
|
(-alpha..alpha).each do |al|
|
@@ -33,13 +33,16 @@ class HistogramOutputTest < Test::Unit::TestCase
|
|
33
33
|
alpha = 0
|
34
34
|
f = create_driver(%[
|
35
35
|
bin_num #{bin_num}
|
36
|
-
alpha #{alpha}]
|
37
|
-
|
38
|
-
f.
|
36
|
+
alpha #{alpha}],
|
37
|
+
"test.input")
|
38
|
+
f.run do
|
39
|
+
f.emit({"keys" => "input key"})
|
40
|
+
f.emit({"keys" => "another key"})
|
41
|
+
end
|
39
42
|
hist = f.instance.zero_hist.dup
|
40
|
-
id = "
|
43
|
+
id = "input key"[0..9].codepoints.collect{|cp| cp}.join().to_i % bin_num
|
41
44
|
hist[id] += 1
|
42
|
-
id = "
|
45
|
+
id = "another key"[0..9].codepoints.collect{|cp| cp}.join().to_i % bin_num
|
43
46
|
hist[id] += 1
|
44
47
|
assert_equal({"test.input" => {:hist => hist, :sum => 2, :avg => 2/bin_num, :sd=>0}},
|
45
48
|
f.instance.flush)
|
@@ -50,15 +53,18 @@ class HistogramOutputTest < Test::Unit::TestCase
|
|
50
53
|
alpha = 1
|
51
54
|
f = create_driver(%[
|
52
55
|
bin_num #{bin_num}
|
53
|
-
alpha #{alpha}]
|
54
|
-
|
55
|
-
f.
|
56
|
+
alpha #{alpha}],
|
57
|
+
"test.input")
|
58
|
+
f.run do
|
59
|
+
f.emit({"keys" => "A"})
|
60
|
+
f.emit({"keys" => "B"})
|
61
|
+
end
|
56
62
|
hist = f.instance.zero_hist.dup
|
57
|
-
id = "A".
|
63
|
+
id = "A".ord % bin_num
|
58
64
|
hist[id] += 2
|
59
65
|
hist[(id + alpha) % bin_num] += 1
|
60
66
|
hist[id - alpha] += 1
|
61
|
-
id = "B".
|
67
|
+
id = "B".ord % bin_num
|
62
68
|
hist[id] += 2
|
63
69
|
hist[(id + alpha) % bin_num] += 1
|
64
70
|
hist[id - alpha] += 1
|
@@ -136,7 +142,7 @@ class HistogramOutputTest < Test::Unit::TestCase
|
|
136
142
|
|
137
143
|
def test_some_hist_exist_case_tagging_with_emit
|
138
144
|
f = create_driver
|
139
|
-
data =
|
145
|
+
data = "A"
|
140
146
|
f.run do
|
141
147
|
["test.a", "test.b", "test.c"].each do |tag|
|
142
148
|
f.instance.increment(tag, data)
|