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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZDc5YjIxNDUwZmM0MjA5N2VhMzMwNWY5NTU0ZTg5N2FmMmY2Zjk2Ng==
4
+ MTUxMjBkOGI3NTZmZGY2MzY2ZTg5MzcwODZlYjBkYjVmYmEzZjE3Mw==
5
5
  data.tar.gz: !binary |-
6
- NDRjZTllMzE2ZGVmMmEyMzM1YTJhZTMwOTQ3YjA3NjhmZWI3MTEwNw==
6
+ Mjc4MTFkYzMyODIwZjE5NDJjNWI2ZjFiYjk0NmViNGE3ODU1ZjNmYQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NjVlM2M1ODY1NDU0NzQ2MDE0YzAzZWRiYTM3NWFiZjQwOTA0MzVjOTc5MmI3
10
- ZjBjZGNhOWQ4YjhjOWI0YjM3YTFmMDFiNjY2ZjRiOTU2NWNkYTBjMjJmZWJj
11
- MzM2YjY5MTEyMWMyZjBiNDU2NGNmMDhkNDI1ODQwYmE3ZmFlNDk=
9
+ MzQwYTFiYjlhMTMzYzdlMzdkNWNmYTdhZGU2NWZkOGIwNGI2YzdkZDk2OTZj
10
+ NzlhNGQzYzllZDQ1MjZjMzliMzVkM2Q2ZjFhNDkxZDQxYmJiMWU2OWU3YmEy
11
+ MGVmNDIwYmIwNjUzNzI2MjI4Y2NiMGNlZWZiMWMxNGMyYmI3MGY=
12
12
  data.tar.gz: !binary |-
13
- ZmUzMDY3MzVkYjY0ZmMxZmU0MmRhMzdhMDM1YTMwZDkwY2MyN2Q5OTdlZjZm
14
- MmYyZTdiNmFhOWQzODNjNTg0YmQ0ZWYxYmI1YjFhOTczYjNmNDNiZjRhNGI2
15
- YTBhYmMzM2RkMWUzNzBkNTMyOTM3YzZjMGI3ZDFhMmI1ZDYzZjI=
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.1.4"
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
- id = key.hash % @bin_num
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
- f.instance.increment("test.input", "A")
38
- f.instance.increment("test.input", "B")
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 = "A".hash % bin_num
43
+ id = "input key"[0..9].codepoints.collect{|cp| cp}.join().to_i % bin_num
41
44
  hist[id] += 1
42
- id = "B".hash % bin_num
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
- f.instance.increment("test.input", "A")
55
- f.instance.increment("test.input", "B")
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".hash % bin_num
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".hash % bin_num
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 = {"keys" => ["A", "B", "C"]}
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-histogram
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yusuke SHIMIZU