resque-metrics 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -4,20 +4,22 @@ GEM
4
4
  archive-tar-minitar (0.5.2)
5
5
  columnize (0.3.4)
6
6
  git (1.2.5)
7
- jeweler (1.6.2)
7
+ jeweler (1.6.4)
8
8
  bundler (~> 1.0)
9
9
  git (>= 1.2.5)
10
10
  rake
11
11
  linecache19 (0.5.12)
12
12
  ruby_core_source (>= 0.1.4)
13
- minitest (2.3.1)
13
+ minitest (2.8.0)
14
14
  multi_json (1.0.3)
15
- rack (1.3.3)
16
- rake (0.9.2)
17
- redis (2.2.0)
15
+ rack (1.3.5)
16
+ rack-protection (1.1.4)
17
+ rack
18
+ rake (0.9.2.2)
19
+ redis (2.2.2)
18
20
  redis-namespace (1.0.3)
19
21
  redis (< 3.0.0)
20
- resque (1.19.0.1)
22
+ resque (1.19.0)
21
23
  multi_json (~> 1.0)
22
24
  redis-namespace (~> 1.0.2)
23
25
  sinatra (>= 0.9.2)
@@ -32,9 +34,10 @@ GEM
32
34
  ruby-debug-base19 (>= 0.11.19)
33
35
  ruby_core_source (0.1.5)
34
36
  archive-tar-minitar (>= 0.5.2)
35
- sinatra (1.2.7)
36
- rack (~> 1.1)
37
- tilt (< 2.0, >= 1.2.2)
37
+ sinatra (1.3.1)
38
+ rack (>= 1.3.4, ~> 1.3)
39
+ rack-protection (>= 1.1.2, ~> 1.1)
40
+ tilt (>= 1.3.3, ~> 1.3)
38
41
  tilt (1.3.3)
39
42
  vegas (0.1.8)
40
43
  rack (>= 1.0.0)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -82,12 +82,22 @@ module Resque
82
82
  run_callback(:on_job_fork, job_class, queue, time)
83
83
  end
84
84
 
85
- def self.record_job_enqueue(job_class)
85
+ def self.record_job_enqueue(job_class, *args)
86
86
  queue = Resque.queue_from_class(job_class)
87
87
  increment_metric "enqueue_count"
88
88
  increment_metric "enqueue_count:job:#{job_class}"
89
89
  increment_metric "enqueue_count:queue:#{queue}"
90
- run_callback(:on_job_enqueue, job_class, queue)
90
+
91
+ size = Resque.encode(args).length
92
+ redis.multi do
93
+ increment_metric "payload_size", size
94
+ increment_metric "payload_size:queue:#{queue}", size
95
+ increment_metric "payload_size:job:#{job_class}", size
96
+ end
97
+ set_metric "avg_payload_size", total_payload_size / total_enqueue_count
98
+ set_metric "avg_payload_size:queue:#{queue}", total_payload_size_by_queue(queue) / total_enqueue_count_by_queue(queue)
99
+ set_metric "avg_payload_size:job:#{job_class}", total_payload_size_by_job(job_class) / total_enqueue_count_by_job(job_class)
100
+ run_callback(:on_job_enqueue, job_class, queue, size)
91
101
  true
92
102
  end
93
103
 
@@ -167,6 +177,30 @@ module Resque
167
177
  get_metric "job_count:job:#{job}"
168
178
  end
169
179
 
180
+ def self.total_payload_size
181
+ get_metric "payload_size"
182
+ end
183
+
184
+ def self.total_payload_size_by_queue(queue)
185
+ get_metric "payload_size:queue:#{queue}"
186
+ end
187
+
188
+ def self.total_payload_size_by_job(job)
189
+ get_metric "payload_size:job:#{job}"
190
+ end
191
+
192
+ def self.avg_payload_size
193
+ get_metric "avg_payload_size"
194
+ end
195
+
196
+ def self.avg_payload_size_by_queue(queue)
197
+ get_metric "avg_payload_size:queue:#{queue}"
198
+ end
199
+
200
+ def self.avg_payload_size_by_job(job)
201
+ get_metric "avg_payload_size:job:#{job}"
202
+ end
203
+
170
204
  def self.avg_fork_time
171
205
  get_metric "avg_fork_time"
172
206
  end
@@ -206,7 +240,7 @@ module Resque
206
240
  module Hooks
207
241
 
208
242
  def after_enqueue_metrics(*args)
209
- Resque::Metrics.record_job_enqueue(self)
243
+ Resque::Metrics.record_job_enqueue(self, *args)
210
244
  end
211
245
 
212
246
  def around_perform_metrics(*args)
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "resque-metrics"
8
- s.version = "0.0.2"
8
+ s.version = "0.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Aaron Quint"]
12
- s.date = "2011-10-06"
12
+ s.date = "2011-11-17"
13
13
  s.description = "A simple Resque plugin that times and saves some simple metrics for Resque jobs back into redis. Based on this system\nyou could build some simple auto-scaling mechanism based on the speed and ETA of queues. Also includes a hook/callback\nmechanism for recording/sending the metrics to your favorite tool (AKA statsd/graphite).\n"
14
14
  s.email = "aaron@quirkey.com"
15
15
  s.extra_rdoc_files = [
@@ -41,6 +41,12 @@ class TestResqueMetrics < MiniTest::Unit::TestCase
41
41
  assert Resque::Metrics.total_job_count_by_job(SomeJob) > 0
42
42
  end
43
43
 
44
+ def test_should_record_payload_size
45
+ assert Resque::Metrics.total_payload_size > 0
46
+ assert Resque::Metrics.total_payload_size_by_queue(:jobs) > 0
47
+ assert Resque::Metrics.total_payload_size_by_job(SomeJob) > 0
48
+ end
49
+
44
50
  def test_should_record_avg_job_time
45
51
  assert Resque::Metrics.avg_job_time > 0
46
52
  assert Resque::Metrics.avg_job_time_by_queue(:jobs) > 0
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-metrics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-06 00:00:00.000000000Z
12
+ date: 2011-11-17 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: resque
16
- requirement: &70186901120320 !ruby/object:Gem::Requirement
16
+ requirement: &70250343371240 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '1.19'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70186901120320
24
+ version_requirements: *70250343371240
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: ruby-debug19
27
- requirement: &70186901113560 !ruby/object:Gem::Requirement
27
+ requirement: &70250343370740 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70186901113560
35
+ version_requirements: *70250343370740
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: minitest
38
- requirement: &70186901112120 !ruby/object:Gem::Requirement
38
+ requirement: &70250343370180 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '2'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70186901112120
46
+ version_requirements: *70250343370180
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
- requirement: &70186901110860 !ruby/object:Gem::Requirement
49
+ requirement: &70250343369600 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.0.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70186901110860
57
+ version_requirements: *70250343369600
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: jeweler
60
- requirement: &70186901108680 !ruby/object:Gem::Requirement
60
+ requirement: &70250343368880 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: 1.6.2
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70186901108680
68
+ version_requirements: *70250343368880
69
69
  description: ! 'A simple Resque plugin that times and saves some simple metrics for
70
70
  Resque jobs back into redis. Based on this system
71
71
 
@@ -110,7 +110,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
110
110
  version: '0'
111
111
  segments:
112
112
  - 0
113
- hash: 1965452822166595860
113
+ hash: -633739306956696608
114
114
  required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  none: false
116
116
  requirements: