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 +4 -4
- data/README.md +0 -1
- data/fluent-plugin-werkzeug-profiler.gemspec +1 -1
- data/lib/fluent/plugin/in_werkzeug_profiler.rb +17 -14
- data/test/plugin/test_in_werkzeug_profiler.rb +2 -2
- 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: ba8a708d8a7a06a3434405c7e77cbaa6d780c559
|
4
|
+
data.tar.gz: 1fde09e5c3eade17545b63b0ef8c38751a18ced6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d457048ad51aafda8231654efc58e3785759a7fa12dd0093f63f583cebce92dd1437035b1b4b13588964f44345fb186792a749608d47e4eed98fda12b79e0b65
|
7
|
+
data.tar.gz: a5f268da4cb554bdbddfe9848f7ef01addaf36836cbdf873d4992aab523a7a025a2afecfea0e3a88bf1c0da416132e0865c5b8e482a0eea261b053217d9e3c5a
|
data/README.md
CHANGED
@@ -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.
|
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
|
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(
|
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 =
|
41
|
-
@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.
|
65
|
+
@time = Time.now.to_i
|
66
66
|
next
|
67
67
|
end
|
68
68
|
|
69
|
-
|
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
|
-
|
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
|
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
|