request-log-analyzer 1.5.4 → 1.6.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.
- data/lib/request_log_analyzer.rb +1 -1
- data/lib/request_log_analyzer/file_format/postgresql.rb +66 -0
- data/lib/request_log_analyzer/file_format/rails.rb +2 -2
- data/lib/request_log_analyzer/output/fixed_width.rb +1 -1
- data/request-log-analyzer.gemspec +4 -4
- data/spec/fixtures/postgresql.log +2980 -0
- data/spec/unit/file_format/postgresql_format_spec.rb +65 -0
- data/spec/unit/file_format/rails_format_spec.rb +8 -2
- data/tasks/github-gem.rake +6 -1
- metadata +10 -6
@@ -0,0 +1,65 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
describe RequestLogAnalyzer::FileFormat::Postgresql do
|
4
|
+
|
5
|
+
it "should be a valid file format" do
|
6
|
+
RequestLogAnalyzer::FileFormat.load(:Postgresql).should be_valid
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '#parse_line' do
|
10
|
+
before(:each) do
|
11
|
+
@file_format = RequestLogAnalyzer::FileFormat.load(:Postgresql)
|
12
|
+
end
|
13
|
+
|
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')
|
17
|
+
end
|
18
|
+
|
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,")
|
22
|
+
end
|
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)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#parse_io' do
|
31
|
+
before(:each) do
|
32
|
+
@log_parser = RequestLogAnalyzer::Source::LogParser.new(RequestLogAnalyzer::FileFormat.load(:postgresql))
|
33
|
+
end
|
34
|
+
|
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
|
47
|
+
@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"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
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
|
+
end
|
64
|
+
end
|
65
|
+
|
@@ -80,11 +80,17 @@ describe RequestLogAnalyzer::FileFormat::Rails do
|
|
80
80
|
@rails.should parse_line(line).as(:failure).and_capture(:error => 'NoMethodError', :message => "undefined method `update_domain_account' for nil:NilClass")
|
81
81
|
end
|
82
82
|
|
83
|
-
it "should parse a :cache_hit line correctly" do
|
84
|
-
line = prefix + 'Filter chain halted as [#<ActionController::Caching::Actions::ActionCacheFilter:0x2a999ad620 @check=nil, @options={:store_options=>{}, :layout=>nil, :cache_path=>#<Proc:0x0000002a999b8890@/app/controllers/cached_controller.rb:8>}
|
83
|
+
it "should parse a :cache_hit line correctly with an filter instance reference" do
|
84
|
+
line = prefix + 'Filter chain halted as [#<ActionController::Filters::AroundFilter:0x2a999ad120 @identifier=nil, @kind=:filter, @options={:only=>#<Set: {"cached"}>, :if=>:not_logged_in?, :unless=>nil}, @method=#<ActionController::Caching::Actions::ActionCacheFilter:0x2a999ad620 @check=nil, @options={:store_options=>{}, :layout=>nil, :cache_path=>#<Proc:0x0000002a999b8890@/app/controllers/cached_controller.rb:8>}>>] did_not_yield.'
|
85
85
|
@rails.should parse_line(line).as(:cache_hit)
|
86
86
|
end
|
87
87
|
|
88
|
+
it "should parse a :cache_hit line correctly with an proc instance reference" do
|
89
|
+
line = prefix + 'Filter chain halted as [#<ActionController::Filters::AroundFilter:0x2a9a923e38 @method=#<Proc:0x0000002a9818b3f8@/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_controller/caching/actions.rb:64>, @kind=:filter, @identifier=nil, @options={:unless=>nil, :if=>nil, :only=>#<Set: {"show"}>}>] did_not_yield.'
|
90
|
+
@rails.should parse_line(line).as(:cache_hit)
|
91
|
+
end
|
92
|
+
|
93
|
+
|
88
94
|
it "should parse a :parameters line correctly" do
|
89
95
|
line = prefix + ' Parameters: {"action"=>"cached", "controller"=>"cached"}'
|
90
96
|
@rails.should parse_line(line).as(:parameters).and_capture(:params => {:action => 'cached', :controller => 'cached'})
|
data/tasks/github-gem.rake
CHANGED
@@ -124,7 +124,7 @@ module GithubGem
|
|
124
124
|
desc "Perform all checks that would occur before a release"
|
125
125
|
task(:release_checks => checks)
|
126
126
|
|
127
|
-
release_tasks = [:release_checks, :set_version, :build, :github_release]
|
127
|
+
release_tasks = [:release_checks, :set_version, :build, :github_release, :gemcutter_release]
|
128
128
|
release_tasks << [:rubyforge_release] if gemspec.rubyforge_project
|
129
129
|
|
130
130
|
desc "Release a new verison of the gem"
|
@@ -132,6 +132,7 @@ module GithubGem
|
|
132
132
|
|
133
133
|
task(:check_rubyforge) { check_rubyforge_task }
|
134
134
|
task(:rubyforge_release) { rubyforge_release_task }
|
135
|
+
task(:gemcutter_release) { gemcutter_release_task }
|
135
136
|
task(:github_release => [:commit_modified_files, :tag_version]) { github_release_task }
|
136
137
|
task(:tag_version) { tag_version_task }
|
137
138
|
task(:commit_modified_files) { commit_modified_files_task }
|
@@ -228,6 +229,10 @@ module GithubGem
|
|
228
229
|
def rubyforge_release_task
|
229
230
|
sh 'rubyforge', 'add_release', gemspec.rubyforge_project, gemspec.name, gemspec.version.to_s, "pkg/#{gemspec.name}-#{gemspec.version}.gem"
|
230
231
|
end
|
232
|
+
|
233
|
+
def gemcutter_release_task
|
234
|
+
sh "gem push pkg/#{gemspec.name}-#{gemspec.version}.gem"
|
235
|
+
end
|
231
236
|
|
232
237
|
# Gem release task.
|
233
238
|
# All work is done by the task's dependencies, so just display a release completed message.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: request-log-analyzer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Willem van Bergen
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date:
|
13
|
+
date: 2010-01-08 00:00:00 +01:00
|
14
14
|
default_executable: request-log-analyzer
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -74,10 +74,10 @@ files:
|
|
74
74
|
- lib/request_log_analyzer/filter.rb
|
75
75
|
- spec/integration/scout_spec.rb
|
76
76
|
- spec/fixtures/test_file_format.log
|
77
|
+
- spec/unit/filter/timespan_filter_spec.rb
|
77
78
|
- lib/request_log_analyzer/tracker/traffic.rb
|
78
79
|
- spec/unit/file_format/merb_format_spec.rb
|
79
80
|
- spec/unit/file_format/format_autodetection_spec.rb
|
80
|
-
- spec/unit/filter/timespan_filter_spec.rb
|
81
81
|
- spec/unit/file_format/file_format_api_spec.rb
|
82
82
|
- lib/request_log_analyzer/filter/field.rb
|
83
83
|
- lib/request_log_analyzer/file_format/merb.rb
|
@@ -87,6 +87,7 @@ files:
|
|
87
87
|
- spec/integration/mailer_spec.rb
|
88
88
|
- lib/request_log_analyzer/line_definition.rb
|
89
89
|
- spec/unit/tracker/frequency_tracker_spec.rb
|
90
|
+
- spec/fixtures/postgresql.log
|
90
91
|
- spec/fixtures/multiple_files_2.log
|
91
92
|
- spec/lib/mocks.rb
|
92
93
|
- spec/unit/file_format/apache_format_spec.rb
|
@@ -107,10 +108,10 @@ files:
|
|
107
108
|
- lib/request_log_analyzer/file_format/rack.rb
|
108
109
|
- lib/request_log_analyzer/tracker/numeric_value.rb
|
109
110
|
- spec/fixtures/test_language_combined.log
|
111
|
+
- spec/unit/request_spec.rb
|
110
112
|
- lib/cli/command_line_arguments.rb
|
111
113
|
- lib/request_log_analyzer.rb
|
112
114
|
- spec/database.yml
|
113
|
-
- spec/unit/request_spec.rb
|
114
115
|
- lib/request_log_analyzer/database/base.rb
|
115
116
|
- spec/unit/aggregator/database_inserter_spec.rb
|
116
117
|
- lib/request_log_analyzer/database/request.rb
|
@@ -123,6 +124,7 @@ files:
|
|
123
124
|
- spec/unit/tracker/duration_tracker_spec.rb
|
124
125
|
- spec/fixtures/rails_22_cached.log
|
125
126
|
- lib/request_log_analyzer/aggregator/summarizer.rb
|
127
|
+
- spec/unit/file_format/postgresql_format_spec.rb
|
126
128
|
- spec/unit/file_format/common_regular_expressions_spec.rb
|
127
129
|
- spec/fixtures/rails_1x.log
|
128
130
|
- lib/request_log_analyzer/file_format/delayed_job.rb
|
@@ -132,13 +134,14 @@ files:
|
|
132
134
|
- spec/unit/file_format/mysql_format_spec.rb
|
133
135
|
- request-log-analyzer.gemspec
|
134
136
|
- spec/fixtures/apache_common.log
|
137
|
+
- spec/unit/mailer_spec.rb
|
135
138
|
- lib/request_log_analyzer/file_format/rails.rb
|
136
139
|
- Rakefile
|
137
|
-
- spec/unit/mailer_spec.rb
|
138
140
|
- lib/request_log_analyzer/tracker/hourly_spread.rb
|
139
141
|
- spec/unit/aggregator/summarizer_spec.rb
|
140
142
|
- spec/unit/tracker/traffic_tracker_spec.rb
|
141
143
|
- spec/unit/tracker/numeric_value_tracker_spec.rb
|
144
|
+
- lib/request_log_analyzer/file_format/postgresql.rb
|
142
145
|
- lib/request_log_analyzer/tracker/timespan.rb
|
143
146
|
- spec/unit/controller/log_processor_spec.rb
|
144
147
|
- spec/fixtures/sinatra.log
|
@@ -209,9 +212,9 @@ test_files:
|
|
209
212
|
- spec/unit/filter/filter_spec.rb
|
210
213
|
- spec/unit/database/connection_spec.rb
|
211
214
|
- spec/integration/scout_spec.rb
|
215
|
+
- spec/unit/filter/timespan_filter_spec.rb
|
212
216
|
- spec/unit/file_format/merb_format_spec.rb
|
213
217
|
- spec/unit/file_format/format_autodetection_spec.rb
|
214
|
-
- spec/unit/filter/timespan_filter_spec.rb
|
215
218
|
- spec/unit/file_format/file_format_api_spec.rb
|
216
219
|
- spec/integration/mailer_spec.rb
|
217
220
|
- spec/unit/tracker/frequency_tracker_spec.rb
|
@@ -225,6 +228,7 @@ test_files:
|
|
225
228
|
- spec/unit/aggregator/database_inserter_spec.rb
|
226
229
|
- spec/unit/filter/anonymize_filter_spec.rb
|
227
230
|
- spec/unit/tracker/duration_tracker_spec.rb
|
231
|
+
- spec/unit/file_format/postgresql_format_spec.rb
|
228
232
|
- spec/unit/file_format/common_regular_expressions_spec.rb
|
229
233
|
- spec/unit/file_format/line_definition_spec.rb
|
230
234
|
- spec/unit/file_format/mysql_format_spec.rb
|