vinted-resque-metrics 0.0.8 → 0.0.9

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: 831cac5b7a1ccf7e90b5e7664b64d59420cb5886
4
- data.tar.gz: fdda7947e280f0bb69a7caf9a51cc6a3ab754820
3
+ metadata.gz: 73195eb6742bfda14f028c14bd649ba39d655b6e
4
+ data.tar.gz: 9d62fd17a960a456328cc8d314bbd06d8e6549c9
5
5
  SHA512:
6
- metadata.gz: 48fdc505e6696e9e9b4c898cbeca615d6787e147916435c0ca5dbef1252cae6e093ced3814117f1491d47c878327109230c836eccf26fe62a68bd4682212d0de
7
- data.tar.gz: 47d3babeffb92bad83f078b84e99a2689a3ed73a5d030f67f6d43cc4e833456d53875eafea55b7b21fa45073542ae9df85d96d46029bd47b38a6960e64e1ed42
6
+ metadata.gz: 8316ad9a9120cda254d0a016eb1586f8169f87c8d65e82c60d0176e83b80fdacd4722df893411c50a3be454f5f072febb399ca9024dc3a165239fee36fca4505
7
+ data.tar.gz: 7c265c7c692e6a45a645f6dc58ebce7a3e788864a6bbaaafbe7de3db1b66364268e68f2792d9396fedf609b7c760c9009af30f5bbd27883925ecd294f771e897
data/README.rdoc CHANGED
@@ -14,7 +14,7 @@ If you are using bundler add this to your Gemfile
14
14
 
15
15
  And if you want the web-ui extensions
16
16
 
17
- gem "resque-metrics", :require => "resque-metrics/server"
17
+ gem "resque-metrics", :require => "resque/metrics/server"
18
18
 
19
19
  == Usage
20
20
 
@@ -31,7 +31,7 @@ Given a job, extend the job class with Resque::Metrics.
31
31
 
32
32
  end
33
33
 
34
- By default this will record the total job count, the total count of jobs enqueued, the total time the jobs took, the avg time the jobs took. It will also record the total number of job failures.
34
+ By default this will record the total job count, the total count of jobs enqueued, the total time the jobs took, the avg time the jobs took. It will also record the total number of job failures.
35
35
  These metrics are also tracked by queue and job class. So for the job above, it will record values and you will be able to fetch them
36
36
  with module methods:
37
37
 
@@ -52,7 +52,7 @@ All values are recorded and returned as integers. For times, values are in milli
52
52
 
53
53
  === Forking Metrics
54
54
 
55
- Resque::Metrics can also record forking metrics but these are not on by default as `before_fork` and `after_fork` are singluar hooks.
55
+ Resque::Metrics can also record forking metrics but these are not on by default as `before_fork` and `after_fork` are singluar hooks.
56
56
  If you don't need to define your own fork hooks you can simply add a line to an initializer:
57
57
 
58
58
  Resque::Metrics.watch_fork
@@ -63,11 +63,11 @@ If you do define you're own fork hooks:
63
63
  # my own fork code
64
64
  Resque::Metrics.before_fork.call(job)
65
65
  end
66
-
66
+
67
67
  # Resque::Metrics.(before/after)_fork just returns a lambda so just assign it if you like
68
68
  Resque.after_fork = Resque::Metrics.after_fork
69
69
 
70
- Once enabled this will add `.*_fork_*` methods like `avg_fork_time`, etc.
70
+ Once enabled this will add `.*_fork_*` methods like `avg_fork_time`, etc.
71
71
  Latest Resque is required for fork recording to work.
72
72
 
73
73
  === Queue Depth Metrics
@@ -146,7 +146,7 @@ the first backend that responds_to? it.
146
146
  === Callbacks/Hooks
147
147
 
148
148
  Resque::Metrics also has a simple callback/hook system so you can send data to your favorite agent. All hooks are passed the job class,
149
- the queue, and the time of the metric.
149
+ the queue, and the time of the metric.
150
150
 
151
151
  # Also `on_job_fork`, `on_job_enqueue`, and `on_job_failure` (`on_job_failure does not include `time`)
152
152
  Resque::Metrics.on_job_complete do |job_class, queue, time|
@@ -155,9 +155,9 @@ the queue, and the time of the metric.
155
155
  Statsd.increment "resque.#{job_class}.complete"
156
156
  # etc
157
157
  end
158
-
158
+
159
159
  == Contributing to resque-metrics
160
-
160
+
161
161
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
162
162
  * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
163
163
  * Fork the project
@@ -0,0 +1,64 @@
1
+ <h1>All your metrics are belong to Resque</h1>
2
+
3
+ <table class="queues">
4
+ <tbody>
5
+ <tr>
6
+ <th>Queue</th>
7
+ <th>Jobs completed</th>
8
+ </tr>
9
+
10
+ <% resque.queues.each do |queue| %>
11
+ <tr>
12
+ <td class="queue"><a href="<%=u "queues/#{queue}" %>"><%= queue %></a></td>
13
+ <td class="size"><%= Resque::Metrics.total_job_count_by_queue(queue) %></td>
14
+ </tr>
15
+ <% end %>
16
+
17
+ <tr class="failed">
18
+ <td class="queue failed"></td>
19
+ <td class="size"><%= Resque::Metrics.total_job_count %></td>
20
+ </tr>
21
+ </tbody>
22
+ </table>
23
+
24
+ <table class="queues">
25
+ <tbody>
26
+ <tr>
27
+ <th>Queue</th>
28
+ <th>Average job time</th>
29
+ </tr>
30
+
31
+ <% resque.queues.each do |queue| %>
32
+ <tr>
33
+ <td class="queue"><a href="<%=u "queues/#{queue}" %>"><%= queue %></a></td>
34
+ <td class="size"><%= metrics_formatted_ms(Resque::Metrics.avg_job_time_by_queue(queue)) %></td>
35
+ </tr>
36
+ <% end %>
37
+
38
+ <tr class="failed">
39
+ <td class="queue failed"></td>
40
+ <td class="size"><%= metrics_formatted_ms(Resque::Metrics.avg_job_time) %></td>
41
+ </tr>
42
+ </tbody>
43
+ </table>
44
+
45
+ <table class="queues">
46
+ <tbody>
47
+ <tr>
48
+ <th>Queue</th>
49
+ <th>Total job time</th>
50
+ </tr>
51
+
52
+ <% resque.queues.each do |queue| %>
53
+ <tr>
54
+ <td class="queue"><a href="<%=u "queues/#{queue}" %>"><%= queue %></a></td>
55
+ <td class="size"><%= metrics_formatted_ms(Resque::Metrics.total_job_time_by_queue(queue)) %></td>
56
+ </tr>
57
+ <% end %>
58
+
59
+ <tr class="failed">
60
+ <td class="queue failed"></td>
61
+ <td class="size"><%= metrics_formatted_ms(Resque::Metrics.total_job_time) %></td>
62
+ </tr>
63
+ </tbody>
64
+ </table>
@@ -0,0 +1,46 @@
1
+ require 'resque/server'
2
+ require 'resque/metrics'
3
+
4
+ # Extend Resque::Server to add tabs
5
+ module Resque
6
+ module Metrics
7
+ module Server
8
+ def self.included(base)
9
+ base.class_eval do
10
+ helpers do
11
+ # reads a 'local' template file.
12
+ def local_template(path)
13
+ # Is there a better way to specify alternate template locations with sinatra?
14
+ File.read(File.join(File.dirname(__FILE__), "server/views/#{path}"))
15
+ end
16
+
17
+ def metrics_formatted_ms(milliseconds)
18
+ seconds = milliseconds / 1000
19
+ hours = (seconds / 3600).floor
20
+ minutes = (seconds % 3600) / 60
21
+ seconds = seconds % 60
22
+
23
+ str = []
24
+ str << "#{hours} hours" if hours > 0
25
+ str << "#{minutes} minutes" if minutes > 0
26
+ str << "#{seconds} seconds" if seconds > 0
27
+ str << "Less than a second" if milliseconds < 1000
28
+
29
+ str.join(" ")
30
+ end
31
+ end
32
+
33
+ get "/metrics" do
34
+ erb local_template("metrics.erb")
35
+ end
36
+ end
37
+ end
38
+
39
+ Resque::Server.tabs << 'Metrics'
40
+ end
41
+ end
42
+ end
43
+
44
+ Resque::Server.class_eval do
45
+ include Resque::Metrics::Server
46
+ end
@@ -6,7 +6,7 @@
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "vinted-resque-metrics"
9
- s.version = "0.0.8"
9
+ s.version = "0.0.9"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
@@ -28,9 +28,11 @@ Gem::Specification.new do |s|
28
28
  "VERSION",
29
29
  "lib/resque-metrics.rb",
30
30
  "lib/resque/metrics.rb",
31
+ "lib/resque/metrics/server.rb",
31
32
  "lib/resque/metrics/backends.rb",
32
33
  "lib/resque/metrics/backends/redis.rb",
33
34
  "lib/resque/metrics/backends/statsd.rb",
35
+ "lib/resque/metrics/server/views/metrics.erb",
34
36
  "resque-metrics.gemspec",
35
37
  "test/helper.rb",
36
38
  "test/redis-test.conf",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vinted-resque-metrics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Quint
@@ -104,6 +104,8 @@ files:
104
104
  - lib/resque/metrics/backends.rb
105
105
  - lib/resque/metrics/backends/redis.rb
106
106
  - lib/resque/metrics/backends/statsd.rb
107
+ - lib/resque/metrics/server.rb
108
+ - lib/resque/metrics/server/views/metrics.erb
107
109
  - resque-metrics.gemspec
108
110
  - test/helper.rb
109
111
  - test/redis-test.conf