log-analyzer 0.2.0 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9f8d3ab240961adfb8a7a8f95f38b19ab967dc88
4
- data.tar.gz: c07499a1e0a7001e39cba2d8ccb606e3f066aa9e
3
+ metadata.gz: e5a384366b1d5db2d56e84cd9da5f5f03ba27543
4
+ data.tar.gz: b71bec30b86641038690a2032d23417952e9659b
5
5
  SHA512:
6
- metadata.gz: c070b05e228ea3539d920b4a2bcee2552d96787bc5e9127537860d8d5e3e333860ae82ff4d16bcd97f09427e2d0a33813c70bc198665848b4bc287259c8818fa
7
- data.tar.gz: 0549d9c8cd21aaba0df5c722f41e7f9ffdb10c1ee95eeeb3e4ab739f3ce83d65298cdcb4dcf145d86bde5e83cb9c58ea52bda4eb3b47644ae7183612c94ad94c
6
+ metadata.gz: 632a21412bff9769262c034fe1c9e4084a1ad9b219d04dd35f6c3692109d06fd0e9eb0c62b85da034206922e026457f8f6a28c49eafb05d3644d18e7994e3c6b
7
+ data.tar.gz: 34958a2ba673033b6fc42ad4e2a9cdef9ac31b458afc06d3d4bbd44dd79502cfe15d4d3cc736e5863882a1e4ed613fe8fbff6ea718018abaf978e94abfc5b2c9
@@ -26,9 +26,14 @@ module Log::Analyzer
26
26
  matche = router.serve(req)
27
27
  next unless matche.any?
28
28
 
29
+ req.env.delete_if { |key, val| ["REQUEST_METHOD", "PATH_INFO"].include?(key) }
29
30
  _, _, route = matche.first
30
31
  endpoint = Endpoint.find_by(method: route.path.request_method, uri_pattern: route.path.uri_pattern)
31
32
  endpoint.count += 1
33
+
34
+ req.env.each do |key, val|
35
+ endpoint[key.downcase] << val.to_i
36
+ end
32
37
  end
33
38
  end
34
39
  Endpoint.all
@@ -21,12 +21,22 @@ module Log::Analyzer
21
21
  column('method')
22
22
  column('endpoint')
23
23
  column('count')
24
+ @endpoints.first.values.keys.each do |key|
25
+ column("#{key}(avg)")
26
+ column("#{key}(max)")
27
+ column("#{key}(min)")
28
+ end
24
29
  end
25
30
  @endpoints.each do |endpoint|
26
31
  row color: 'red' do
27
32
  column(endpoint.method)
28
33
  column(endpoint.uri_pattern)
29
34
  column(endpoint.count)
35
+ endpoint.values.each do |_, val|
36
+ column(val.inject(0.0, :+).quo(val.count).round(2))
37
+ column(val.max)
38
+ column(val.min)
39
+ end
30
40
  end
31
41
  end
32
42
  end
@@ -2,11 +2,15 @@ module Log::Analyzer
2
2
  class Endpoint
3
3
  attr_accessor :method, :uri_pattern, :count, :values
4
4
 
5
- def initialize(method: "", uri_pattern: "", values: Hash.new(0))
5
+ def initialize(method: "", uri_pattern: "")
6
6
  @method = method
7
7
  @uri_pattern = uri_pattern
8
8
  @count = 0
9
- @values = values
9
+ @values = {}
10
+ end
11
+
12
+ def [](key)
13
+ @values[key] ||= []
10
14
  end
11
15
 
12
16
  def self.create(method: "", uri_pattern: "")
@@ -1,5 +1,5 @@
1
1
  module Log
2
2
  module Analyzer
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: log-analyzer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - shiro16
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-02 00:00:00.000000000 Z
11
+ date: 2016-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack