request-log-analyzer 1.5.3 → 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.
@@ -0,0 +1,83 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe RequestLogAnalyzer::FileFormat::DelayedJob do
4
+
5
+ it "should be a valid file format" do
6
+ RequestLogAnalyzer::FileFormat.load(:delayed_job).should be_valid
7
+ end
8
+
9
+ describe '#parse_line' do
10
+ before(:each) do
11
+ @file_format = RequestLogAnalyzer::FileFormat.load(:delayed_job)
12
+ end
13
+
14
+ it "should parse a :job_lock line correctly" do
15
+ line = "* [JOB] acquiring lock on BackgroundJob::ThumbnailSaver"
16
+ @file_format.should parse_line(line).as(:job_lock).and_capture(:job => 'BackgroundJob::ThumbnailSaver')
17
+ end
18
+
19
+ it "should parse a :job_completed line correctly" do
20
+ line = '* [JOB] BackgroundJob::ThumbnailSaver completed after 0.7932'
21
+ @file_format.should parse_line(line).as(:job_completed).and_capture(
22
+ :duration => 0.7932, :completed_job => 'BackgroundJob::ThumbnailSaver')
23
+ end
24
+
25
+ it "should pase a :job_failed line correctly" do
26
+ line = "* [JOB] BackgroundJob::ThumbnailSaver failed with ActiveRecord::RecordNotFound: Couldn't find Design with ID=20413443 - 1 failed attempts"
27
+ @file_format.should parse_line(line).as(:job_failed).and_capture(:attempts => 1,
28
+ :failed_job => 'BackgroundJob::ThumbnailSaver', :exception => 'ActiveRecord::RecordNotFound')
29
+ end
30
+
31
+ it "" do
32
+ line = "* [JOB] failed to acquire exclusive lock for BackgroundJob::ThumbnailSaver"
33
+ @file_format.should parse_line(line).as(:job_lock_failed).and_capture(:locked_job => 'BackgroundJob::ThumbnailSaver')
34
+ end
35
+
36
+ # it "should pase a :batch_completed line correctly" do
37
+ # line = '1 jobs processed at 1.0834 j/s, 0 failed ...'
38
+ # @file_format.should parse_line(line).as(:batch_completed).and_capture(
39
+ # :mean_duration => 0.7932, :total_amount => 1, :failed_amount => 0)
40
+ # end
41
+
42
+ end
43
+
44
+ describe '#parse_io' do
45
+ before(:each) do
46
+ @log_parser = RequestLogAnalyzer::Source::LogParser.new(RequestLogAnalyzer::FileFormat.load(:delayed_job))
47
+ end
48
+
49
+ it "should parse a batch of completed jobs without warnings" do
50
+ fragment = "* [JOB] acquiring lock on BackgroundJob::ThumbnailSaver
51
+ * [JOB] BackgroundJob::ThumbnailSaver completed after 0.9114
52
+ * [JOB] acquiring lock on BackgroundJob::ThumbnailSaver
53
+ * [JOB] BackgroundJob::ThumbnailSaver completed after 0.9110
54
+ 2 jobs processed at 1.0832 j/s, 0 failed ..."
55
+
56
+ request_counter.should_receive(:hit!).exactly(2).times
57
+ @log_parser.should_not_receive(:warn)
58
+
59
+ @log_parser.parse_io(StringIO.new(fragment)) do |request|
60
+ request_counter.hit! if request.kind_of?(RequestLogAnalyzer::FileFormat::DelayedJob::Request)
61
+ end
62
+ end
63
+
64
+ it "should parse a batch with a failed job without warnings" do
65
+ fragment = "* [JOB] acquiring lock on BackgroundJob::ThumbnailSaver
66
+ * [JOB] BackgroundJob::ThumbnailSaver completed after 1.0627
67
+ * [JOB] acquiring lock on BackgroundJob::ThumbnailSaver
68
+ * [JOB] BackgroundJob::ThumbnailSaver failed with ActiveRecord::RecordNotFound: Couldn't find Design with ID=20413443 - 3 failed attempts
69
+ Couldn't find Design with ID=20413443
70
+ * [JOB] acquiring lock on BackgroundJob::ThumbnailSaver
71
+ * [JOB] failed to acquire exclusive lock for BackgroundJob::ThumbnailSaver
72
+ 2 jobs processed at 1.4707 j/s, 1 failed ..."
73
+
74
+ request_counter.should_receive(:hit!).exactly(3).times
75
+ @log_parser.should_not_receive(:warn)
76
+
77
+ @log_parser.parse_io(StringIO.new(fragment)) do |request|
78
+ request_counter.hit! if request.kind_of?(RequestLogAnalyzer::FileFormat::DelayedJob::Request)
79
+ end
80
+ end
81
+ end
82
+ end
83
+
@@ -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>}>] rendered_or_redirected.'
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'})
@@ -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.5.3
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: 2009-12-14 00:00:00 +01:00
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,12 +87,14 @@ 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
93
94
  - spec/fixtures/syslog_1x.log
94
95
  - spec/integration/munin_plugins_rails_spec.rb
95
96
  - spec/lib/helpers.rb
97
+ - spec/unit/file_format/delayed_job_format_spec.rb
96
98
  - spec/fixtures/rails.db
97
99
  - spec/unit/source/log_parser_spec.rb
98
100
  - lib/request_log_analyzer/aggregator/database_inserter.rb
@@ -106,10 +108,10 @@ files:
106
108
  - lib/request_log_analyzer/file_format/rack.rb
107
109
  - lib/request_log_analyzer/tracker/numeric_value.rb
108
110
  - spec/fixtures/test_language_combined.log
111
+ - spec/unit/request_spec.rb
109
112
  - lib/cli/command_line_arguments.rb
110
113
  - lib/request_log_analyzer.rb
111
114
  - spec/database.yml
112
- - spec/unit/request_spec.rb
113
115
  - lib/request_log_analyzer/database/base.rb
114
116
  - spec/unit/aggregator/database_inserter_spec.rb
115
117
  - lib/request_log_analyzer/database/request.rb
@@ -119,24 +121,27 @@ files:
119
121
  - lib/request_log_analyzer/database/warning.rb
120
122
  - spec/unit/filter/anonymize_filter_spec.rb
121
123
  - spec/fixtures/apache_combined.log
124
+ - spec/unit/tracker/duration_tracker_spec.rb
122
125
  - spec/fixtures/rails_22_cached.log
123
126
  - lib/request_log_analyzer/aggregator/summarizer.rb
124
- - spec/unit/tracker/duration_tracker_spec.rb
127
+ - spec/unit/file_format/postgresql_format_spec.rb
125
128
  - spec/unit/file_format/common_regular_expressions_spec.rb
126
129
  - spec/fixtures/rails_1x.log
130
+ - lib/request_log_analyzer/file_format/delayed_job.rb
127
131
  - lib/request_log_analyzer/output.rb
128
132
  - spec/unit/file_format/line_definition_spec.rb
129
133
  - lib/request_log_analyzer/file_format/mysql.rb
130
134
  - spec/unit/file_format/mysql_format_spec.rb
131
135
  - request-log-analyzer.gemspec
132
136
  - spec/fixtures/apache_common.log
137
+ - spec/unit/mailer_spec.rb
133
138
  - lib/request_log_analyzer/file_format/rails.rb
134
139
  - Rakefile
135
- - spec/unit/mailer_spec.rb
136
140
  - lib/request_log_analyzer/tracker/hourly_spread.rb
137
141
  - spec/unit/aggregator/summarizer_spec.rb
138
142
  - spec/unit/tracker/traffic_tracker_spec.rb
139
143
  - spec/unit/tracker/numeric_value_tracker_spec.rb
144
+ - lib/request_log_analyzer/file_format/postgresql.rb
140
145
  - lib/request_log_analyzer/tracker/timespan.rb
141
146
  - spec/unit/controller/log_processor_spec.rb
142
147
  - spec/fixtures/sinatra.log
@@ -207,14 +212,15 @@ test_files:
207
212
  - spec/unit/filter/filter_spec.rb
208
213
  - spec/unit/database/connection_spec.rb
209
214
  - spec/integration/scout_spec.rb
215
+ - spec/unit/filter/timespan_filter_spec.rb
210
216
  - spec/unit/file_format/merb_format_spec.rb
211
217
  - spec/unit/file_format/format_autodetection_spec.rb
212
- - spec/unit/filter/timespan_filter_spec.rb
213
218
  - spec/unit/file_format/file_format_api_spec.rb
214
219
  - spec/integration/mailer_spec.rb
215
220
  - spec/unit/tracker/frequency_tracker_spec.rb
216
221
  - spec/unit/file_format/apache_format_spec.rb
217
222
  - spec/integration/munin_plugins_rails_spec.rb
223
+ - spec/unit/file_format/delayed_job_format_spec.rb
218
224
  - spec/unit/source/log_parser_spec.rb
219
225
  - spec/unit/file_format/rails_format_spec.rb
220
226
  - spec/integration/command_line_usage_spec.rb
@@ -222,6 +228,7 @@ test_files:
222
228
  - spec/unit/aggregator/database_inserter_spec.rb
223
229
  - spec/unit/filter/anonymize_filter_spec.rb
224
230
  - spec/unit/tracker/duration_tracker_spec.rb
231
+ - spec/unit/file_format/postgresql_format_spec.rb
225
232
  - spec/unit/file_format/common_regular_expressions_spec.rb
226
233
  - spec/unit/file_format/line_definition_spec.rb
227
234
  - spec/unit/file_format/mysql_format_spec.rb