sidekiq-queue-stats 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/.travis.yml +8 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +8 -0
- data/LICENSE +22 -0
- data/README.md +37 -0
- data/Rakefile +12 -0
- data/lib/sidekiq-queue-stats.rb +1 -0
- data/lib/sidekiq/queue_stats.rb +17 -0
- data/lib/sidekiq/queue_stats/version.rb +5 -0
- data/lib/sidekiq/queue_stats/views/queue_stats.erb +63 -0
- data/lib/sidekiq/queue_stats/web_extension.rb +38 -0
- data/sidekiq-queue-stats.gemspec +24 -0
- data/test/test_helper.rb +14 -0
- data/test/web_extension_test.rb +31 -0
- metadata +130 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a2dc2eb1a1491761dcf29003723af76103d87708
|
4
|
+
data.tar.gz: 9ead0cf4014a3fc517b4fa6b5617834831c49f57
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ddd68453e02c0d79bd2fb44f050679f91c5256b62cca537ee8cf6e984e69a5f88a4527dbc4bce272114030ea7725f1ad4fd9b5f052665f88badde4114380ba27
|
7
|
+
data.tar.gz: 1ca1e20ad688623141a35976c3ba5088ae8ded9be46822c8c71946db3fb8866f05e91d446af3f07122d8957644fd9b3ff3d6170397cb6ce8aa6aa17b54e90867
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
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,37 @@
|
|
1
|
+
# Sidekiq::QueueStats [![Build Status](https://travis-ci.org/mikestephens/sidekiq-queue-stats.svg?branch=master)](https://travis-ci.org/mikestephens/sidekiq-queue-stats)
|
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-queue-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
|
+
![Web UI](http://i.imgur.com/eSNVK0O.png)
|
21
|
+
## Dependencies
|
22
|
+
|
23
|
+
Depends on Sidekiq >= 2.16.0
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create new Pull Request
|
32
|
+
|
33
|
+
## License
|
34
|
+
|
35
|
+
Released under the MIT License. See the [LICENSE][license] file for further details.
|
36
|
+
|
37
|
+
[license]: https://github.com/mhfs/sidekiq-queue-count/blob/master/LICENSE
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "sidekiq/queue_stats"
|
@@ -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/queue_stats/version"
|
9
|
+
require "sidekiq/queue_stats/web_extension"
|
10
|
+
|
11
|
+
module Sidekiq
|
12
|
+
end
|
13
|
+
|
14
|
+
if defined?(Sidekiq::Web)
|
15
|
+
Sidekiq::Web.register Sidekiq::QueueStats::WebExtension
|
16
|
+
Sidekiq::Web.tabs["Worker Stats"] = "queue_stats"
|
17
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
<header class="row">
|
2
|
+
<div class="col-sm-5">
|
3
|
+
<h3>Queue Stats</h3>
|
4
|
+
</div>
|
5
|
+
</header>
|
6
|
+
|
7
|
+
<div class="dropdown pull-right">
|
8
|
+
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
|
9
|
+
Queues
|
10
|
+
<span class="caret"></span>
|
11
|
+
</button>
|
12
|
+
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
|
13
|
+
<li><a href="?queue=all">All</a></li>
|
14
|
+
<% @queues.each do |q| %>
|
15
|
+
<li><a href=<%="?queue=#{q.downcase}"%>><%= q.capitalize %></a></li>
|
16
|
+
<% end %>
|
17
|
+
</ul>
|
18
|
+
</div>
|
19
|
+
|
20
|
+
<%= csrf_tag if respond_to?(:csrf_tag) %>
|
21
|
+
<% if params[:queue] == "all" %>
|
22
|
+
<% @queues.each do |q| %>
|
23
|
+
<h4><%= q.capitalize %></h4>
|
24
|
+
<% if @workers[q].empty? %>
|
25
|
+
<div class="alert alert-success">Nothing waiting in queue</div>
|
26
|
+
<% else %>
|
27
|
+
<table class="table table-striped table-bordered table-white">
|
28
|
+
<thead>
|
29
|
+
<tr>
|
30
|
+
<th>Name</th>
|
31
|
+
<th style="width: 150px">Count</th>
|
32
|
+
</tr>
|
33
|
+
</thead>
|
34
|
+
<% @workers[q].each do |worker| %>
|
35
|
+
<tr>
|
36
|
+
<td><%=worker.first%></td>
|
37
|
+
<td><%=worker.last%></td>
|
38
|
+
</tr>
|
39
|
+
<% end %>
|
40
|
+
</table>
|
41
|
+
<% end %>
|
42
|
+
<% end %>
|
43
|
+
<% else %>
|
44
|
+
<h4><%= @queue.name.capitalize %></h4>
|
45
|
+
<% if @workers[@queue].nil? %>
|
46
|
+
<div class="alert alert-success">Nothing waiting in queue</div>
|
47
|
+
<% else %>
|
48
|
+
<table class="table table-striped table-bordered table-white">
|
49
|
+
<thead>
|
50
|
+
<tr>
|
51
|
+
<th>Name</th>
|
52
|
+
<th style="width: 150px">Count</th>
|
53
|
+
</tr>
|
54
|
+
</thead>
|
55
|
+
<% @workers[@queue.name].each do |worker| %>
|
56
|
+
<tr>
|
57
|
+
<td><%=worker.first%></td>
|
58
|
+
<td><%=worker.last%></td>
|
59
|
+
</tr>
|
60
|
+
<% end %>
|
61
|
+
</table>
|
62
|
+
<% end %>
|
63
|
+
<% end %>
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Sidekiq
|
2
|
+
module QueueStats
|
3
|
+
module WebExtension
|
4
|
+
|
5
|
+
def self.registered(app)
|
6
|
+
view_path = File.join(File.expand_path("..", __FILE__), "views")
|
7
|
+
|
8
|
+
app.get "/queue_stats" do
|
9
|
+
@queues = Sidekiq::Queue.all.map(&:name)
|
10
|
+
@workers = {}
|
11
|
+
|
12
|
+
if params[:queue] == "all"
|
13
|
+
Sidekiq::Queue.all.each do |q|
|
14
|
+
@workers[q.name] = {}
|
15
|
+
total = q.map{|cue| cue.klass}
|
16
|
+
klasses = total.uniq
|
17
|
+
klasses.each do |klass|
|
18
|
+
@workers[q.name][klass] = total.count(klass)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
else
|
22
|
+
@queue = params[:queue] ? Sidekiq::Queue.new(params[:queue]) : Sidekiq::Queue.new
|
23
|
+
@workers[@queue.name] = {}
|
24
|
+
total = @queue.map{|cue| cue.klass}
|
25
|
+
klasses = total.uniq
|
26
|
+
if klasses
|
27
|
+
klasses.each do |klass|
|
28
|
+
@workers[@queue.name][klass] = total.count(klass)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
render(:erb, File.read(File.join(view_path, "worker_stats.erb")))
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/sidekiq/queue_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 queue stats}
|
8
|
+
gem.summary = %q{Keeps track of Sidekiq queue stats to see total counts of each job.}
|
9
|
+
gem.homepage = "https://github.com/mikestephens/sidekiq-queue-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-queue-stats"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Sidekiq::QueueStats::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
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "minitest/autorun"
|
2
|
+
require "minitest/spec"
|
3
|
+
require "minitest/mock"
|
4
|
+
require "rack/test"
|
5
|
+
|
6
|
+
require "sidekiq"
|
7
|
+
require "sidekiq-queue-stats"
|
8
|
+
require "sidekiq/processor"
|
9
|
+
require "sidekiq/fetch"
|
10
|
+
require "sidekiq/cli"
|
11
|
+
|
12
|
+
Sidekiq.logger.level = Logger::ERROR
|
13
|
+
|
14
|
+
REDIS = Sidekiq::RedisConnection.create(url: "redis://localhost/15")
|
@@ -0,0 +1,31 @@
|
|
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 queue stats tab' do
|
18
|
+
get '/'
|
19
|
+
last_response.status.must_equal 200
|
20
|
+
last_response.body.must_match /Sidekiq/
|
21
|
+
last_response.body.must_match /Queue Stats/
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'can display queue stats page without any failures' do
|
25
|
+
get '/queue_stats'
|
26
|
+
last_response.status.must_equal 200
|
27
|
+
last_response.body.must_match /Queue Stats/
|
28
|
+
last_response.body.must_match /Default/
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sidekiq-queue-stats
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
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 queue 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-queue-stats.rb
|
98
|
+
- lib/sidekiq/queue_stats.rb
|
99
|
+
- lib/sidekiq/queue_stats/version.rb
|
100
|
+
- lib/sidekiq/queue_stats/views/queue_stats.erb
|
101
|
+
- lib/sidekiq/queue_stats/web_extension.rb
|
102
|
+
- sidekiq-queue-stats.gemspec
|
103
|
+
- test/test_helper.rb
|
104
|
+
- test/web_extension_test.rb
|
105
|
+
homepage: https://github.com/mikestephens/sidekiq-queue-stats/
|
106
|
+
licenses: []
|
107
|
+
metadata: {}
|
108
|
+
post_install_message:
|
109
|
+
rdoc_options: []
|
110
|
+
require_paths:
|
111
|
+
- lib
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
requirements: []
|
123
|
+
rubyforge_project:
|
124
|
+
rubygems_version: 2.4.5
|
125
|
+
signing_key:
|
126
|
+
specification_version: 4
|
127
|
+
summary: Keeps track of Sidekiq queue stats to see total counts of each job.
|
128
|
+
test_files:
|
129
|
+
- test/test_helper.rb
|
130
|
+
- test/web_extension_test.rb
|