sidekiq-expected_failures 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -3,6 +3,7 @@
3
3
  .bundle
4
4
  .config
5
5
  .yardoc
6
+ .rvmrc
6
7
  Gemfile.lock
7
8
  InstalledFiles
8
9
  _yardoc
data/.travis.yml CHANGED
@@ -2,6 +2,8 @@ language: ruby
2
2
 
3
3
  rvm:
4
4
  - 1.9.3
5
+ - jruby-19mode
6
+ - rbx
5
7
  - 2.0.0
6
8
 
7
9
  services:
data/CHANGELOG.md CHANGED
@@ -1,3 +1,20 @@
1
+ ## 0.2.1
2
+
3
+ - added JSON stats path in case you would like to fetch this data from external service.
4
+ It works similar to sidekiq's _stats_. You can visit: `expected_failures/stats` to
5
+ get a JSON response with global counters (PR #4)
6
+
7
+ ``` json
8
+ {
9
+
10
+ "failures": {
11
+ "ExceptionName": "123",
12
+ "Other::ExceptionName": "10",
13
+ }
14
+
15
+ }
16
+ ```
17
+
1
18
  ## 0.2.0
2
19
 
3
20
  - [**breaking change**] ability to use Sidekiq's build-in `handle_exception`
data/Gemfile CHANGED
@@ -1,4 +1,8 @@
1
1
  source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in sidekiq-expected_failures.gemspec
4
2
  gemspec
3
+
4
+ platforms :rbx do
5
+ gem "rubysl", "~> 2.0" # if using anything in the ruby standard library
6
+ gem "rubinius-developer_tools", "~> 2.0.0" # if using any of coverage, debugger, profiler
7
+ gem "minitest" # if using minitest
8
+ end
data/README.md CHANGED
@@ -3,6 +3,8 @@
3
3
  [![Code Climate](https://codeclimate.com/github/emq/sidekiq-expected_failures.png)](https://codeclimate.com/github/emq/sidekiq-expected_failures)
4
4
  [![Build Status](https://travis-ci.org/emq/sidekiq-expected_failures.png?branch=master)](https://travis-ci.org/emq/sidekiq-expected_failures)
5
5
  [![Coverage Status](https://coveralls.io/repos/emq/sidekiq-expected_failures/badge.png)](https://coveralls.io/r/emq/sidekiq-expected_failures)
6
+ [![Dependency Status](https://gemnasium.com/emq/sidekiq-expected_failures.png)](https://gemnasium.com/emq/sidekiq-expected_failures)
7
+ [![Gem Version](https://badge.fury.io/rb/sidekiq-expected_failures.png)](http://badge.fury.io/rb/sidekiq-expected_failures)
6
8
 
7
9
  If you don't rely on standard sidekiq's retry behavior and you want to track exceptions, that will happen one way, or another - this thing is for you.
8
10
 
@@ -54,7 +56,7 @@ This is how web interface looks like:
54
56
 
55
57
  ![](http://i.imgur.com/7Fe8voD.jpg)
56
58
 
57
- It logs each failed jobs to to redis list (per day) and keep global counters (per exception class as a single redis hash).
59
+ It logs each failed jobs to to redis list (per day) and keep global counters (per exception class as a single redis hash). If you would like to get that counter as JSON response (for some external API usage for example) you can use path `expected_failures/stats`.
58
60
 
59
61
  ### Default expected failures
60
62
 
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module ExpectedFailures
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
5
5
  end
@@ -21,6 +21,15 @@ module Sidekiq
21
21
  redirect "#{root_path}expected_failures"
22
22
  end
23
23
 
24
+ app.get "/expected_failures/stats" do
25
+ @counters = Sidekiq::ExpectedFailures.counters
26
+
27
+ content_type :json
28
+ Sidekiq.dump_json({
29
+ failures: @counters
30
+ })
31
+ end
32
+
24
33
  app.get "/expected_failures/?:date?" do
25
34
  @dates = Sidekiq::ExpectedFailures.dates
26
35
  @count = (params[:count] || 50).to_i
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "rake"
24
24
  spec.add_development_dependency "sinatra"
25
25
  spec.add_development_dependency "rack-test"
26
- spec.add_development_dependency "timecop", "~> 0.6.3"
26
+ spec.add_development_dependency "timecop", "~> 0.7.0"
27
27
  spec.add_development_dependency "mocha", "~> 0.14.0"
28
28
  spec.add_development_dependency "coveralls", "~> 0.7.0"
29
29
  end
data/test/lib/web_test.rb CHANGED
@@ -135,5 +135,33 @@ module Sidekiq
135
135
  end
136
136
  end
137
137
  end
138
+
139
+ describe 'stats' do
140
+ describe 'when there are no errors' do
141
+ before do
142
+ get '/expected_failures/stats'
143
+ @response = Sidekiq.load_json(last_response.body)
144
+ end
145
+
146
+ it 'can return failures json without any failures' do
147
+ last_response.status.must_equal(200)
148
+ assert_equal({}, @response['failures'])
149
+ end
150
+ end
151
+
152
+ describe 'when there are errors' do
153
+ before do
154
+ create_sample_counter
155
+ get '/expected_failures/stats'
156
+ @response = Sidekiq.load_json(last_response.body)
157
+ end
158
+
159
+ it 'can return json with failures' do
160
+ last_response.status.must_equal(200)
161
+ assert_equal "5", @response['failures']['StandardError']
162
+ assert_equal "10", @response['failures']['Custom::Error']
163
+ end
164
+ end
165
+ end
138
166
  end
139
167
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-expected_failures
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-12-01 00:00:00.000000000 Z
12
+ date: 2013-12-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sidekiq
@@ -98,7 +98,7 @@ dependencies:
98
98
  requirements:
99
99
  - - ~>
100
100
  - !ruby/object:Gem::Version
101
- version: 0.6.3
101
+ version: 0.7.0
102
102
  type: :development
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
@@ -106,7 +106,7 @@ dependencies:
106
106
  requirements:
107
107
  - - ~>
108
108
  - !ruby/object:Gem::Version
109
- version: 0.6.3
109
+ version: 0.7.0
110
110
  - !ruby/object:Gem::Dependency
111
111
  name: mocha
112
112
  requirement: !ruby/object:Gem::Requirement
@@ -182,7 +182,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
182
182
  version: '0'
183
183
  segments:
184
184
  - 0
185
- hash: 3929689485539629877
185
+ hash: 2728967153757439761
186
186
  required_rubygems_version: !ruby/object:Gem::Requirement
187
187
  none: false
188
188
  requirements:
@@ -191,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
191
  version: '0'
192
192
  segments:
193
193
  - 0
194
- hash: 3929689485539629877
194
+ hash: 2728967153757439761
195
195
  requirements: []
196
196
  rubyforge_project:
197
197
  rubygems_version: 1.8.25