fluent-plugin-werkzeug-profiler 0.0.2 → 0.0.3

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: 2d88f53035956160f4255509118afc6e52b40872
4
- data.tar.gz: da5bd8332bb05e7f2d927ae08492a13f30ec4614
3
+ metadata.gz: ba8a708d8a7a06a3434405c7e77cbaa6d780c559
4
+ data.tar.gz: 1fde09e5c3eade17545b63b0ef8c38751a18ced6
5
5
  SHA512:
6
- metadata.gz: 93bcde63025e9687664e2a39d05689f85371af4446998560da19f357dba8b56cebefb5b46b4f73df46da50a7ad73313a2d983b52ec15c0712bec51875a05e64c
7
- data.tar.gz: 4315d7a0e9abc2ae591dfcc4c3235d25f49e408b59b39fb0d231c8f0a813cf38120dbf7fbd3c09afb8b6416ab6417efe4253a6698e64c2dc3e82c61b008a1e11
6
+ metadata.gz: d457048ad51aafda8231654efc58e3785759a7fa12dd0093f63f583cebce92dd1437035b1b4b13588964f44345fb186792a749608d47e4eed98fda12b79e0b65
7
+ data.tar.gz: a5f268da4cb554bdbddfe9848f7ef01addaf36836cbdf873d4992aab523a7a025a2afecfea0e3a88bf1c0da416132e0865c5b8e482a0eea261b053217d9e3c5a
data/README.md CHANGED
@@ -50,7 +50,6 @@ $ gem install fluent-plugin-werkzeug-profiler
50
50
  type werkzeug_profiler
51
51
  path path/to/werkzeug.log
52
52
  tag werkzeug.webserver
53
- time_format %d-%b-%Y:%H:%M:%S
54
53
  </source>
55
54
  ```
56
55
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = "fluent-plugin-werkzeug-profiler"
5
- gem.version = "0.0.2"
5
+ gem.version = "0.0.3"
6
6
  gem.authors = ["Kenta MORI"]
7
7
  gem.email = ["zoncoen@gmail.com"]
8
8
  gem.description = %q{Fluent input plugin for Werkzeug WSGI application profiler statistics.}
@@ -3,12 +3,9 @@ module Fluent
3
3
  class WerkzeugProfilerInput < TailInput
4
4
  Plugin.register_input('werkzeug_profiler', self)
5
5
 
6
- # get time format from config
7
- config_param :time_format, :string, :default => '%d/%b/%Y:%H:%M:%S %z'
8
-
9
6
  # override
10
7
  def configure_parser(conf)
11
- @parser = WerkzeugProfilerParser.new(@time_format)
8
+ @parser = WerkzeugProfilerParser.new
12
9
  end
13
10
 
14
11
  # override
@@ -33,12 +30,11 @@ module Fluent
33
30
  end
34
31
 
35
32
  class WerkzeugProfilerParser
36
- def initialize(time_format)
37
- @time_format = time_format
33
+ def initialize()
38
34
  @keys = ['uri', 'tot_ncalls', 'prim_ncalls', 'tottime', 'tot_percall', 'cumtime', 'cum_percall', 'filename:lineno(function)']
39
35
  @record_size = @keys.length - 2
40
- @path = 'path'
41
- @time = 'time'
36
+ @path = nil
37
+ @time = nil
42
38
  end
43
39
 
44
40
  def parse(values)
@@ -50,25 +46,32 @@ module Fluent
50
46
 
51
47
  def divide(lines)
52
48
  records = []
53
- # remove empty lines
54
- lines = lines.join('').gsub(/\n\n/, "\n").split("\n")
55
49
 
56
50
  for line in lines do
51
+ # remove empty lines
52
+ if line == "\n"
53
+ next
54
+ end
55
+
57
56
  if line.start_with?('-')
58
57
  @path = nil
58
+ @time = nil
59
59
  next
60
60
  end
61
61
 
62
62
  if line.start_with?('PATH:')
63
63
  path = line.split(nil)[1]
64
64
  @path = path[1..path.length-2]
65
- @time = Time.now.strftime(@time_format)
65
+ @time = Time.now.to_i
66
66
  next
67
67
  end
68
68
 
69
- if line.strip.split(nil)[1] == 'function' || line.strip.start_with?('ncalls', 'Ordered', 'List')
69
+
70
+ if @path == nil || @time == nil
71
+ next
72
+ elsif line.split(nil)[1] == 'function' || line.strip.start_with?('ncalls', 'Ordered', 'List')
70
73
  next
71
- elsif @path != nil
74
+ else
72
75
  values = line.split(nil)
73
76
  # divide ncalls
74
77
  ncalls = values[0].split('/')
@@ -86,7 +89,7 @@ module Fluent
86
89
  end
87
90
 
88
91
  # return records as array
89
- records
92
+ return records
90
93
  end
91
94
  end
92
95
  end
@@ -16,7 +16,6 @@ class WerkzeugProfilerInputTest < Test::Unit::TestCase
16
16
 
17
17
  CONFIG = %[
18
18
  path #{TMP_DIR}/werkzeug-profiler-test.txt
19
- time_format %d-%b-%Y:%H:%M:%S
20
19
  tag test
21
20
  ]
22
21
 
@@ -27,7 +26,7 @@ class WerkzeugProfilerInputTest < Test::Unit::TestCase
27
26
  def test_configure
28
27
  d = create_driver
29
28
  assert_equal ["#{TMP_DIR}/werkzeug-profiler-test.txt"], d.instance.paths
30
- assert_equal "%d-%b-%Y:%H:%M:%S", d.instance.time_format
29
+ assert_equal 'test', d.instance.tag
31
30
  end
32
31
 
33
32
  def test_emit
@@ -55,6 +54,7 @@ class WerkzeugProfilerInputTest < Test::Unit::TestCase
55
54
  f.puts ""
56
55
  f.puts "--------------------------------------------------------------------------------"
57
56
  f.puts ""
57
+ f.puts "127.0.0.1 - - [08/Nov/2013 13:16:56] \"GET / HTTP/1.1\" 200 -"
58
58
  }
59
59
  sleep 1
60
60
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-werkzeug-profiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenta MORI