sidekiq-queue-stats 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dbd643a40085110519af1f51bbefae8467022412
4
- data.tar.gz: 9b0138eb0d1ef8930aaf0be0e08b085a51557032
3
+ metadata.gz: 01738da19e87612e68bfe8074757d052f034c850
4
+ data.tar.gz: adcfeca22ffb4173f404194022f002d5a5179eec
5
5
  SHA512:
6
- metadata.gz: f6d04509c58906775525c538bc6d80e53da9acf0f15125ea23549b392fd46184141440e9636cc96307297fbb48ced3227e8b1877dd1939874b2efdcdce17bfd9
7
- data.tar.gz: 28f942925b89a941b53f14dbd62841fa68e689ac1cb80d82e3a95f5da948699a1ac6598ddd1eee800e61cd34a9ddb37ba5cc58d0f7cf7400a4c387efaf156b88
6
+ metadata.gz: f8c5f427fade4a363bfdb13b0facf72cd8af1256adb3c09769d9573c15b8d77ca3e56a213631ffd919ce735e2e9d56e6e46e3da4dc93dc35c41eecef6feec654
7
+ data.tar.gz: 13d186b3597892cbc6065195ddb1f4371d414826266870217c38dd54119366c24aaae663ee34689620e5f16b46a5c88237ef128c4e4c406ebfe0d5143ef3c288
@@ -1,5 +1,8 @@
1
1
  ## Unreleased
2
2
 
3
+ ## 1.4.0
4
+ * Added configuration
5
+
3
6
  ## 0.0.1
4
7
 
5
8
  * Initial release (@mikestephens)
data/README.md CHANGED
@@ -16,6 +16,21 @@ Simply having the gem in your Gemfile is enough to get you started. Your
16
16
  job count will be visible via a Queue Stats tab in the Web UI.
17
17
 
18
18
  ![Web UI](http://i.imgur.com/eSNVK0O.png)
19
+
20
+ ### Configuration
21
+
22
+ Add this block to `config/initializers/sidekiq.rb`
23
+
24
+ ```
25
+ Sidekiq::QueueStats.configure do |config|
26
+ config.max_limit = 50000
27
+ end
28
+ ```
29
+
30
+ #### Max Limit
31
+
32
+ Iterating through large queues can be resource intensive and take quite a lot of time. This option lets you set an integer to only show queue stats of queues under a pre defined threashold.
33
+
19
34
  ## Dependencies
20
35
 
21
36
  Depends on Sidekiq >= 2.16.0
@@ -1 +1,22 @@
1
1
  require "sidekiq/queue_stats"
2
+ require 'sidekiq/queue_stats/configuration'
3
+
4
+ module Sidekiq
5
+ module QueueStats
6
+ class << self
7
+ attr_accessor :configuration
8
+ end
9
+
10
+ def self.configuration
11
+ @configuration ||= Configuration.new
12
+ end
13
+
14
+ def self.reset
15
+ @configuration = Configuration.new
16
+ end
17
+
18
+ def self.configure
19
+ yield(configuration)
20
+ end
21
+ end
22
+ end
@@ -7,6 +7,7 @@ end
7
7
  require "sidekiq/api"
8
8
  require "sidekiq/queue_stats/version"
9
9
  require "sidekiq/queue_stats/web_extension"
10
+ require "sidekiq/queue_stats/configuration"
10
11
 
11
12
  module Sidekiq
12
13
  module QueueStats
@@ -0,0 +1,11 @@
1
+ module Sidekiq
2
+ module QueueStats
3
+ class Configuration
4
+ attr_accessor :max_limit
5
+
6
+ def initialize
7
+ @max_limit = nil
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module QueueStats
3
- VERSION = "1.3.0"
3
+ VERSION = "1.4.0"
4
4
  end
5
5
  end
@@ -34,7 +34,7 @@
34
34
  <% @workers_count[@selected_queue.name].each do |worker| %>
35
35
  <tr>
36
36
  <td><%=worker.first%></td>
37
- <td><%=worker.last%></td>
37
+ <td><%=number_with_delimiter(worker.last)%></td>
38
38
  </tr>
39
39
  <% end %>
40
40
  </table>
@@ -47,6 +47,8 @@
47
47
  <h4><%= q.capitalize %></h4>
48
48
  <% if @workers_count[q].empty? %>
49
49
  <div class="alert alert-success">Nothing waiting in queue</div>
50
+ <% elsif @workers_count[q] == "too_big" %>
51
+ <div class="alert alert-warning">Queue too large to display. Manually select it to see what is in it.</div>
50
52
  <% else %>
51
53
  <table class="table table-striped table-bordered table-white">
52
54
  <thead>
@@ -58,7 +60,7 @@
58
60
  <% @workers_count[q].each do |worker| %>
59
61
  <tr>
60
62
  <td><%=worker.first%></td>
61
- <td><%=worker.last%></td>
63
+ <td><%=number_with_delimiter(worker.last)%></td>
62
64
  </tr>
63
65
  <% end %>
64
66
  </table>
@@ -18,9 +18,13 @@ module QueueStats
18
18
  else
19
19
  queues_list = Sidekiq::Queue.all
20
20
  queues_list.each do |q|
21
- @workers_count[q.name] = Hash.new(0)
22
- q.each do |job|
23
- @workers_count[q.name][job.klass] += 1
21
+ if !Sidekiq::QueueStats.configuration.max_limit.nil? && q.size > Sidekiq::QueueStats.configuration.max_limit
22
+ @workers_count[q.name] = "too_big"
23
+ else
24
+ @workers_count[q.name] = Hash.new(0)
25
+ q.each do |job|
26
+ @workers_count[q.name][job.klass] += 1
27
+ end
24
28
  end
25
29
  end
26
30
  end
@@ -24,7 +24,7 @@ module Sidekiq
24
24
  get '/queue_stats'
25
25
  last_response.status.must_equal 200
26
26
  last_response.body.must_match /Queue Stats/
27
- last_response.body.must_match /Default/
27
+ last_response.body.must_match /Queues/
28
28
  end
29
29
  end
30
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-queue-stats
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Stephens
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-27 00:00:00.000000000 Z
11
+ date: 2016-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sidekiq
@@ -96,6 +96,7 @@ files:
96
96
  - Rakefile
97
97
  - lib/sidekiq-queue-stats.rb
98
98
  - lib/sidekiq/queue_stats.rb
99
+ - lib/sidekiq/queue_stats/configuration.rb
99
100
  - lib/sidekiq/queue_stats/version.rb
100
101
  - lib/sidekiq/queue_stats/views/queue_stats.erb
101
102
  - lib/sidekiq/queue_stats/web_extension.rb