fluent-plugin-calc 0.0.5 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3c4e47d56f27cba7e3e04f0738eb6434456ce824
4
- data.tar.gz: e759f302614709da9350bd0f59a748cc7ab6d724
3
+ metadata.gz: 14fc42370c6cdcf0ffd500ca287940035e54151e
4
+ data.tar.gz: 28b511128dd7c1b714c7e76fdf19c949314e2af3
5
5
  SHA512:
6
- metadata.gz: f9701abea3da09295a09a02fd8867fc882644ef9f980ea2896ea95e953945f8413790494fb784cfd19294f451e1ef0300961e3298619f864629371e20fefffee
7
- data.tar.gz: 1a1d71d9497dc2bfb394eb1cc58c47daed5dd3b4aab686a7388a6ad22218dcba23513d8c0bf41eb5bb09df165373a05138afa0b7682ebf7212d3699c9191a919
6
+ metadata.gz: c02f0ae43c7cd297e243c5d6b97f5a5d9cb693d4197591a97d58878e9bbb397c8bf66e4530038fc71a948c9e0cffd2204d9b27c595714246a30f45fed8843a6b
7
+ data.tar.gz: 52f8f3511d14422be46c3e5de7ddcb00e30d88910f6a4185c2c594e2713f1075bc26fa8a24306e3f9a7e2c46736f034b98b9534c515deb9aa7bae8223c2fd94e
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.1.0 (2013/09/02)
2
+
3
+ Changes
4
+
5
+ - Accept string data by `to_f`.
6
+
1
7
  ## 0.0.5 (2013/09/02)
2
8
 
3
9
  Enhancement:
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "fluent-plugin-calc"
6
- s.version = "0.0.5"
6
+ s.version = "0.1.0"
7
7
  s.authors = ["Naotoshi SEO"]
8
8
  s.email = ["sonots@gmail.com"]
9
9
  s.homepage = "https://github.com/sonots/fluent-plugin-calc"
@@ -79,29 +79,34 @@ class Fluent::CalcOutput < Fluent::Output
79
79
  count = 0; matches = { :sum => {}, :max => {}, :min => {}, :avg => {} }
80
80
  es.each do |time, record|
81
81
  @sum_keys.each do |key|
82
- matches[:sum][key] = sum(matches[:sum][key], record[key])
82
+ value = record[key].to_f if record[key]
83
+ matches[:sum][key] = sum(matches[:sum][key], value)
83
84
  end
84
85
  @max_keys.each do |key|
85
- matches[:max][key] = max(matches[:max][key], record[key])
86
+ value = record[key].to_f if record[key]
87
+ matches[:max][key] = max(matches[:max][key], value)
86
88
  end
87
89
  @min_keys.each do |key|
88
- matches[:min][key] = min(matches[:min][key], record[key])
90
+ value = record[key].to_f if record[key]
91
+ matches[:min][key] = min(matches[:min][key], value)
89
92
  end
90
93
  @avg_keys.each do |key|
91
- matches[:avg][key] = avg(matches[:avg][key], record[key])
94
+ value = record[key].to_f if record[key]
95
+ matches[:avg][key] = avg(matches[:avg][key], value)
92
96
  end
93
97
  record.keys.each do |key|
98
+ value = record[key].to_f
94
99
  if @sum and @sum.match(key)
95
- matches[:sum][key] = sum(matches[:sum][key], record[key])
100
+ matches[:sum][key] = sum(matches[:sum][key], value)
96
101
  end
97
102
  if @max and @max.match(key)
98
- matches[:max][key] = max(matches[:max][key], record[key])
103
+ matches[:max][key] = max(matches[:max][key], value)
99
104
  end
100
105
  if @min and @min.match(key)
101
- matches[:min][key] = min(matches[:min][key], record[key])
106
+ matches[:min][key] = min(matches[:min][key], value)
102
107
  end
103
108
  if @avg and @avg.match(key)
104
- matches[:avg][key] = sum(matches[:avg][key], record[key]) # sum yet
109
+ matches[:avg][key] = sum(matches[:avg][key], value) # sum yet
105
110
  end
106
111
  end if @sum || @max || @min || @avg
107
112
  count += 1
@@ -68,9 +68,9 @@ describe Fluent::CalcOutput do
68
68
  let(:time) { Time.now.to_i }
69
69
  let(:messages) do
70
70
  [
71
- {"4xx_count"=>1,"5xx_count"=>2,"reqtime_max"=>6,"reqtime_min"=>1,"reqtime_avg"=>3},
72
- {"4xx_count"=>2,"5xx_count"=>2,"reqtime_max"=>5,"reqtime_min"=>2,"reqtime_avg"=>2},
73
- {"4xx_count"=>3,"5xx_count"=>2,"reqtime_max"=>1,"reqtime_min"=>3,"reqtime_avg"=>4},
71
+ {"4xx_count"=>"1","5xx_count"=>2,"reqtime_max"=>6,"reqtime_min"=>1,"reqtime_avg"=>3},
72
+ {"4xx_count"=>"2","5xx_count"=>2,"reqtime_max"=>5,"reqtime_min"=>2,"reqtime_avg"=>2},
73
+ {"4xx_count"=>"3","5xx_count"=>2,"reqtime_max"=>1,"reqtime_min"=>3,"reqtime_avg"=>4},
74
74
  ]
75
75
  end
76
76
  let(:emit) do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-calc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi SEO