fluent-plugin-calc 0.0.5 → 0.1.0
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 +4 -4
- data/CHANGELOG.md +6 -0
- data/fluent-plugin-calc.gemspec +1 -1
- data/lib/fluent/plugin/out_calc.rb +13 -8
- data/spec/out_calc_spec.rb +3 -3
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 14fc42370c6cdcf0ffd500ca287940035e54151e
         | 
| 4 | 
            +
              data.tar.gz: 28b511128dd7c1b714c7e76fdf19c949314e2af3
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: c02f0ae43c7cd297e243c5d6b97f5a5d9cb693d4197591a97d58878e9bbb397c8bf66e4530038fc71a948c9e0cffd2204d9b27c595714246a30f45fed8843a6b
         | 
| 7 | 
            +
              data.tar.gz: 52f8f3511d14422be46c3e5de7ddcb00e30d88910f6a4185c2c594e2713f1075bc26fa8a24306e3f9a7e2c46736f034b98b9534c515deb9aa7bae8223c2fd94e
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    
    
        data/fluent-plugin-calc.gemspec
    CHANGED
    
    | @@ -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 | 
| 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 | 
            -
                     | 
| 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 | 
            -
                     | 
| 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 | 
            -
                     | 
| 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 | 
            -
                     | 
| 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],  | 
| 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],  | 
| 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],  | 
| 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],  | 
| 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
         | 
    
        data/spec/out_calc_spec.rb
    CHANGED
    
    | @@ -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
         |