sidekiq-worker-stats 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ca0f848e1d7e64e367a9b92809d4e29cc0fc9f48
4
+ data.tar.gz: 2f0effc33fa028932d2b967e93b7d7eb86346076
5
+ SHA512:
6
+ metadata.gz: 2ea27189580d87f02d48ac618808bb386472dc762a78699b58018e1ef0e6224ead01c30a672441815b1f107f2166ba9b57847c7bb5ff081dfe7f0dee80ddcc5e
7
+ data.tar.gz: 8898d99310f0d992cd85d6fce7f2bcd17abaa977d9e5e442c4ae81ab9c4f7290bc694c8a10535828a8514599d29dafef9f5bf669fbdf9a686d1693c3056ba035
data/.gitignore ADDED
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ InstalledFiles
7
+ _yardoc
8
+ coverage
9
+ doc/
10
+ lib/bundler/man
11
+ pkg
12
+ rdoc
13
+ spec/reports
14
+ test/tmp
15
+ test/version_tmp
16
+ tmp
17
+ Gemfile.lock
18
+ .ruby-version
19
+ .ruby-gemset
20
+
data/.travis.yml ADDED
@@ -0,0 +1,18 @@
1
+ language: ruby
2
+ services:
3
+ - redis-server
4
+ rvm:
5
+ - 1.9.3
6
+ - jruby-19mode
7
+ - 2.0.0
8
+ - 2.1
9
+ env:
10
+ matrix:
11
+ - SIDEKIQ_VERSION="~> 2.16"
12
+ - SIDEKIQ_VERSION="~> 2.17"
13
+ - SIDEKIQ_VERSION="~> 3.0"
14
+ - SIDEKIQ_VERSION="~> 3.1"
15
+ matrix:
16
+ allow_failures:
17
+ - rvm: 1.9.3
18
+ - rvm: jruby-19mode
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## Unreleased
2
+
3
+ ## 0.0.1
4
+
5
+ * Initial release (@mikestephens)
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in sidekiq-failures.gemspec
4
+ gemspec
5
+
6
+ gem 'sidekiq', ENV['SIDEKIQ_VERSION'] if ENV['SIDEKIQ_VERSION']
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 Michael Stephens
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # Sidekiq::WorkerStats [![Build Status](https://secure.travis-ci.org/mhfs/sidekiq-worker-count.png)](http://travis-ci.org/mhfs/sidekiq-worker-count)
2
+
3
+ Keeps track of Sidekiq job count and adds a tab to the Web UI to let you view totals.
4
+
5
+ [WARNING] Large amounts of jobs in queues can cause this gem to slowly load. Use the 'Live Poll' button at your own risk.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'sidekiq-worker-stats'
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ Simply having the gem in your Gemfile is enough to get you started. Your
18
+ job count will be visible via a Worker Stats tab in the Web UI.
19
+
20
+ ## Dependencies
21
+
22
+ Depends on Sidekiq >= 2.16.0
23
+
24
+ ## Contributing
25
+
26
+ 1. Fork it
27
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
28
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
29
+ 4. Push to the branch (`git push origin my-new-feature`)
30
+ 5. Create new Pull Request
31
+
32
+ ## License
33
+
34
+ Released under the MIT License. See the [LICENSE][license] file for further details.
35
+
36
+ [license]: https://github.com/mhfs/sidekiq-worker-count/blob/master/LICENSE
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require "rake/testtask"
4
+
5
+ task :default => :test
6
+
7
+ Rake::TestTask.new do |t|
8
+ t.libs << "lib"
9
+ t.libs << "test"
10
+ t.test_files = FileList["test/**/*_test.rb"]
11
+ t.verbose = true
12
+ end
@@ -0,0 +1,5 @@
1
+ en:
2
+ FailedJobs: Failed Jobs
3
+ FailedAt: Failed At
4
+ ResetCounter: Reset Counter
5
+ NoFailedJobsFound: No failed jobs found
@@ -0,0 +1,5 @@
1
+ module Sidekiq
2
+ module WorkerStats
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,28 @@
1
+ <header class="row">
2
+ <div class="col-sm-5">
3
+ <h3>Worker Stats</h3>
4
+ </div>
5
+ </header>
6
+
7
+ <%= csrf_tag if respond_to?(:csrf_tag) %>
8
+ <% @queues.each do |q| %>
9
+ <h4><%= q.capitalize %></h4>
10
+ <% if @workers[q].empty? %>
11
+ <div>Nothing waiting in queue</div>
12
+ <% else %>
13
+ <table class="table table-striped table-bordered table-white">
14
+ <thead>
15
+ <tr>
16
+ <th>Name</th>
17
+ <th>Count</th>
18
+ </tr>
19
+ </thead>
20
+ <% @workers[q].each do |worker| %>
21
+ <tr>
22
+ <td><%=worker.first%></td>
23
+ <td><%=worker.last%></td>
24
+ </tr>
25
+ <% end %>
26
+ </table>
27
+ <% end %>
28
+ <% end %>
@@ -0,0 +1,25 @@
1
+ module Sidekiq
2
+ module WorkerStats
3
+ module WebExtension
4
+
5
+ def self.registered(app)
6
+ view_path = File.join(File.expand_path("..", __FILE__), "views")
7
+
8
+ app.get "/worker_stats" do
9
+ @queues = Sidekiq::Queue.all.map(&:name)
10
+ @workers = {}
11
+ Sidekiq::Queue.all.each do |q|
12
+ @workers[q.name] = {}
13
+ total = q.map{|cue| cue.klass}
14
+ klasses = total.uniq
15
+ klasses.each do |klass|
16
+ @workers[q.name][klass] = total.count(klass)
17
+ end
18
+ end
19
+
20
+ render(:erb, File.read(File.join(view_path, "worker_stats.erb")))
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,17 @@
1
+ begin
2
+ require "sidekiq/web"
3
+ rescue LoadError
4
+ # client-only usage
5
+ end
6
+
7
+ require "sidekiq/api"
8
+ require "sidekiq/worker_stats/version"
9
+ require "sidekiq/worker_stats/web_extension"
10
+
11
+ module Sidekiq
12
+ end
13
+
14
+ if defined?(Sidekiq::Web)
15
+ Sidekiq::Web.register Sidekiq::WorkerStats::WebExtension
16
+ Sidekiq::Web.tabs["Worker Stats"] = "worker_stats"
17
+ end
@@ -0,0 +1 @@
1
+ require "sidekiq/worker_stats"
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/sidekiq/worker_stats/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Michael Stephens"]
6
+ gem.email = ["michael@stephens.tech"]
7
+ gem.description = %q{Keep track of Sidekiq Worker stats}
8
+ gem.summary = %q{Keeps track of Sidekiq Worker stats to see total counts of each worker in each queue.}
9
+ gem.homepage = "https://github.com/mikestephens/sidekiq-worker-stats/"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "sidekiq-worker-stats"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Sidekiq::WorkerStats::VERSION
17
+
18
+ gem.add_dependency "sidekiq", ">= 2.16.0"
19
+
20
+ gem.add_development_dependency "rake"
21
+ gem.add_development_dependency "rack-test"
22
+ gem.add_development_dependency "sprockets"
23
+ gem.add_development_dependency "sinatra"
24
+ end
@@ -0,0 +1,20 @@
1
+ Encoding.default_external = Encoding::UTF_8
2
+ Encoding.default_internal = Encoding::UTF_8
3
+
4
+ require "minitest/autorun"
5
+ require "minitest/spec"
6
+ require "minitest/mock"
7
+
8
+ require "rack/test"
9
+
10
+ require "celluloid"
11
+ require "sidekiq"
12
+ require "sidekiq-failures"
13
+ require "sidekiq/processor"
14
+ require "sidekiq/fetch"
15
+ require "sidekiq/cli"
16
+
17
+ Celluloid.logger = nil
18
+ Sidekiq.logger.level = Logger::ERROR
19
+
20
+ REDIS = Sidekiq::RedisConnection.create(:url => "redis://localhost/15", :namespace => 'sidekiq_failures_test')
@@ -0,0 +1,32 @@
1
+ require "test_helper"
2
+ require "sidekiq/web"
3
+
4
+ module Sidekiq
5
+ describe "WebExtension" do
6
+ include Rack::Test::Methods
7
+
8
+ def app
9
+ Sidekiq::Web
10
+ end
11
+
12
+ before do
13
+ Sidekiq.redis = REDIS
14
+ Sidekiq.redis {|c| c.flushdb }
15
+ end
16
+
17
+ it 'can display home with worker stats tab' do
18
+ get '/'
19
+
20
+ last_response.status.must_equal 200
21
+ last_response.body.must_match /Sidekiq/
22
+ last_response.body.must_match /Worker Stats/
23
+ end
24
+
25
+ it 'can display worker stats page without any failures' do
26
+ get '/worker_stats'
27
+ last_response.status.must_equal 200
28
+ last_response.body.must_match /Worker Stats/
29
+ last_response.body.must_match /Default/
30
+ end
31
+ end
32
+ end
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sidekiq-worker-stats
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Michael Stephens
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-09-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sidekiq
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 2.16.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 2.16.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rack-test
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: sprockets
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: sinatra
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Keep track of Sidekiq Worker stats
84
+ email:
85
+ - michael@stephens.tech
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".travis.yml"
92
+ - CHANGELOG.md
93
+ - Gemfile
94
+ - LICENSE
95
+ - README.md
96
+ - Rakefile
97
+ - lib/sidekiq-worker-stats.rb
98
+ - lib/sidekiq/worker_stats.rb
99
+ - lib/sidekiq/worker_stats/locales/en.yml
100
+ - lib/sidekiq/worker_stats/version.rb
101
+ - lib/sidekiq/worker_stats/views/worker_stats.erb
102
+ - lib/sidekiq/worker_stats/web_extension.rb
103
+ - sidekiq-worker-stats.gemspec
104
+ - test/test_helper.rb
105
+ - test/web_extension_test.rb
106
+ homepage: https://github.com/mikestephens/sidekiq-worker-stats/
107
+ licenses: []
108
+ metadata: {}
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubyforge_project:
125
+ rubygems_version: 2.4.5
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: Keeps track of Sidekiq Worker stats to see total counts of each worker in
129
+ each queue.
130
+ test_files:
131
+ - test/test_helper.rb
132
+ - test/web_extension_test.rb