request-log-analyzer 1.9.9 → 1.9.10
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/request_log_analyzer.rb +1 -1
- data/lib/request_log_analyzer/controller.rb +28 -28
- data/lib/request_log_analyzer/file_format/postgresql.rb +7 -6
- data/request-log-analyzer.gemspec +2 -2
- data/spec/fixtures/postgresql.log +29 -2980
- data/spec/unit/file_format/postgresql_format_spec.rb +17 -30
- metadata +3 -3
@@ -12,18 +12,18 @@ describe RequestLogAnalyzer::FileFormat::Postgresql do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should parse a :query line correctly" do
|
15
|
-
line = '
|
16
|
-
@file_format.should parse_line(line).as(:query).and_capture(:timestamp =>
|
15
|
+
line = '2010-10-10 13:52:07 GMT [38747]: [33-1] LOG: 00000: duration: 0.710 ms statement: SELECT * FROM "delayed_jobs"'
|
16
|
+
@file_format.should parse_line(line).as(:query).and_capture(:timestamp => 20101010135207, :query_fragment => 'SELECT * FROM "delayed_jobs"')
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should parse a :query_fragment line correctly" do
|
20
|
-
line = '
|
21
|
-
@file_format.should parse_line(line).as(:query_fragment).and_capture(:query_fragment => "
|
20
|
+
line = ' ("failed_at", "locked_by", "created_at", "handler", "updated_at", "priority", "run_at", "attempts", "locked_at",'
|
21
|
+
@file_format.should parse_line(line).as(:query_fragment).and_capture(:query_fragment => '("failed_at", "locked_by", "created_at", "handler", "updated_at", "priority", "run_at", "attempts", "locked_at",')
|
22
22
|
end
|
23
23
|
|
24
|
-
it "should parse a :
|
25
|
-
line = '
|
26
|
-
@file_format.should parse_line(line).as(:
|
24
|
+
it "should parse a :query line correctly" do
|
25
|
+
line = '2010-10-10 13:52:07 GMT [38747]: [33-1] LOG: 00000: duration: 0.710 ms statement: SELECT * FROM "delayed_jobs"'
|
26
|
+
@file_format.should parse_line(line).as(:query).and_capture(:query_time => 0.710)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -33,33 +33,20 @@ describe RequestLogAnalyzer::FileFormat::Postgresql do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
it "should parse a multiline query entry correctly" do
|
36
|
-
fixture =
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
ORDER BY post_date DESC LIMIT 10 OFFSET 0
|
45
|
-
2004-05-07 11:58:22 LOG: duration: 0.002680 sec
|
46
|
-
EOS
|
36
|
+
fixture = <<-EOS
|
37
|
+
2010-10-10 15:00:02 GMT [38747]: [1669-1] LOG: 00000: duration: 0.195 ms statement: INSERT INTO "delayed_jobs" ("failed_at", "locked_by", "created_at", "handler", "updated_at", "priority", "run_at", "attempts", "locked_at", "last_error") VALUES(NULL, NULL, '2010-10-10 15:00:02.159884', E'--- !ruby/object:RuntheChooChootrain {}
|
38
|
+
', '2010-10-10 15:00:02.159884', 0, '2010-10-10 16:00:00.000000', 0, NULL, NULL) RETURNING "id"
|
39
|
+
2010-10-10 15:00:02 GMT [38747]: [1670-1] LOCATION: exec_simple_query, postgres.c:1081
|
40
|
+
EOS
|
41
|
+
|
42
|
+
request_counter.should_receive(:hit!).exactly(1).times
|
43
|
+
@log_parser.should_not_receive(:warn)
|
47
44
|
@log_parser.parse_io(StringIO.new(fixture)) do |request|
|
48
|
-
request.
|
49
|
-
request[:query].should ==
|
45
|
+
request_counter.hit! if request.kind_of?(RequestLogAnalyzer::FileFormat::Postgresql::Request) && request.completed?
|
46
|
+
request[:query].should == 'INSERT INTO delayed_jobs (failed_at, locked_by, created_at, handler, updated_at, priority, run_at, attempts, locked_at, last_error) VALUES(NULL, NULL, :string, E:string, :string, :int, :string, :int, NULL, NULL) RETURNING id'
|
50
47
|
end
|
51
48
|
end
|
52
49
|
|
53
|
-
it "should parse a dualline query entry correctly" do
|
54
|
-
fixture = <<EOS
|
55
|
-
2004-05-07 11:58:36 LOG: query: SELECT type, count FROM project_sums_agg WHERE group_id=59
|
56
|
-
2004-05-07 11:58:36 LOG: duration: 0.001197 sec
|
57
|
-
EOS
|
58
|
-
@log_parser.parse_io(StringIO.new(fixture)) do |request|
|
59
|
-
request.should be_kind_of(RequestLogAnalyzer::FileFormat::Postgresql::Request)
|
60
|
-
request[:query].should == "SELECT type, count FROM project_sums_agg WHERE group_id=:int"
|
61
|
-
end
|
62
|
-
end
|
63
50
|
end
|
64
51
|
end
|
65
52
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 9
|
8
|
-
-
|
9
|
-
version: 1.9.
|
8
|
+
- 10
|
9
|
+
version: 1.9.10
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Willem van Bergen
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-01-03 00:00:00 +01:00
|
19
19
|
default_executable: request-log-analyzer
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|