request-log-analyzer 1.9.9 → 1.9.10

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.
@@ -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 = '2004-05-07 11:58:36 LOG: query: SELECT plugin_id, plugin_name FROM plugins'
16
- @file_format.should parse_line(line).as(:query).and_capture(:timestamp => 20040507115836, :query_fragment => 'SELECT plugin_id, plugin_name FROM plugins')
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 = ' groups.type_id,users.user_name,users.realname,'
21
- @file_format.should parse_line(line).as(:query_fragment).and_capture(:query_fragment => "groups.type_id,users.user_name,users.realname,")
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 :duration line correctly" do
25
- line = '2004-05-07 11:58:36 LOG: duration: 0.002612 sec'
26
- @file_format.should parse_line(line).as(:duration).and_capture(:query_time => 0.002612)
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 = <<EOS
37
- 2004-05-07 11:58:22 LOG: query: SELECT groups.group_name,groups.unix_group_name,
38
- groups.type_id,users.user_name,users.realname,
39
- news_bytes.forum_id,news_bytes.summary,news_bytes.post_date,news_bytes.details
40
- FROM users,news_bytes,groups
41
- WHERE news_bytes.group_id='98' AND news_bytes.is_approved <> '4'
42
- AND users.user_id=news_bytes.submitted_by
43
- AND news_bytes.group_id=groups.group_id
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.should be_kind_of(RequestLogAnalyzer::FileFormat::Postgresql::Request)
49
- request[:query].should == "SELECT groups.group_name,groups.unix_group_name, groups.type_id,users.user_name,users.realname, news_bytes.forum_id,news_bytes.summary,news_bytes.post_date,news_bytes.details FROM users,news_bytes,groups WHERE news_bytes.group_id=:string AND news_bytes.is_approved <> :string AND users.user_id=news_bytes.submitted_by AND news_bytes.group_id=groups.group_id ORDER BY post_date DESC LIMIT :int OFFSET :int"
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
9
- version: 1.9.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: 2010-12-17 00:00:00 -05:00
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