collective-metrics 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/collective.gemspec CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_dependency 'rufus-scheduler', '~> 2.0'
22
22
  spec.add_dependency 'thor', '~> 0.18'
23
- spec.add_dependency 'formatted-metrics', '~> 0.1'
23
+ spec.add_dependency 'formatted-metrics', ['>= 0.2.1', '< 1.0']
24
24
 
25
25
  spec.add_development_dependency 'bundler', '~> 1.3'
26
26
  spec.add_development_dependency 'rake'
@@ -16,5 +16,9 @@ module Collective
16
16
  def instrument(*args, &block)
17
17
  Metrics.instrument(*args, &block)
18
18
  end
19
+
20
+ def group(*args, &block)
21
+ Metrics.group(*args, &block)
22
+ end
19
23
  end
20
24
  end
@@ -3,9 +3,11 @@ module Collective::Collectors
3
3
  requires :dalli
4
4
 
5
5
  collect do
6
- client.stats.each do |server, stats|
7
- stats.each do |metric, value|
8
- instrument "memcached.#{metric}", value, source: server
6
+ Metrics.group 'memcached' do |group|
7
+ client.stats.each do |server, stats|
8
+ stats.each do |metric, value|
9
+ group.instrument metric, value, source: server
10
+ end
9
11
  end
10
12
  end
11
13
  end
@@ -5,10 +5,12 @@ module Collective::Collectors
5
5
  requires :redis
6
6
 
7
7
  collect do
8
- instrument 'redis.used_memory', (info['used_memory'].to_f / MEGABYTE).round(2)
9
- instrument 'redis.connected_clients', info['connected_clients']
10
- instrument 'redis.blocked_clients', info['blocked_clients']
11
- instrument 'redis.connected_slaves', info['connected_slaves']
8
+ group 'redis' do |group|
9
+ group.instrument 'used_memory', (info['used_memory'].to_f / MEGABYTE).round(2)
10
+ group.instrument 'connected_clients', info['connected_clients']
11
+ group.instrument 'blocked_clients', info['blocked_clients']
12
+ group.instrument 'connected_slaves', info['connected_slaves']
13
+ end
12
14
  end
13
15
 
14
16
  private
@@ -3,13 +3,16 @@ module Collective::Collectors
3
3
  requires :sidekiq
4
4
 
5
5
  collect do
6
- instrument 'sidekiq.queues.processed', stats.processed
7
- instrument 'sidekiq.queues.failed', stats.failed
8
- instrument 'sidekiq.queues.enqueued', stats.enqueued
9
- instrument 'sidekiq.workers.busy', workers
6
+ group 'sidekiq' do |group|
7
+ group.instrument 'queues.processed', stats.processed
8
+ group.instrument 'queues.failed', stats.failed
9
+ group.instrument 'queues.enqueued', stats.enqueued
10
+ group.instrument 'workers.busy', workers
10
11
 
11
- queues.each do |queue, depth|
12
- instrument 'sidekiq.queue.enqueued', depth, source: queue
12
+ queues.each do |queue, depth|
13
+ group.instrument 'queue.latency', queue_latency(queue), source: queue
14
+ group.instrument 'queue.enqueued', depth, source: queue
15
+ end
13
16
  end
14
17
  end
15
18
 
@@ -23,6 +26,10 @@ module Collective::Collectors
23
26
  stats.queues
24
27
  end
25
28
 
29
+ def queue_latency(name)
30
+ ::Sidekiq::Queue.new(name).latency rescue 0
31
+ end
32
+
26
33
  def workers
27
34
  ::Sidekiq.redis { |conn|
28
35
  conn
@@ -1,3 +1,3 @@
1
1
  module Collective
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
data/lib/collective.rb CHANGED
@@ -15,7 +15,6 @@ module Collective
15
15
 
16
16
  class << self
17
17
  def run
18
- Metrics.subscribe
19
18
  STDOUT.sync = true
20
19
 
21
20
  builder = Builder.new
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: collective-metrics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-06 00:00:00.000000000 Z
12
+ date: 2013-09-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rufus-scheduler
@@ -48,17 +48,23 @@ dependencies:
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  none: false
50
50
  requirements:
51
- - - ~>
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: 0.2.1
54
+ - - <
52
55
  - !ruby/object:Gem::Version
53
- version: '0.1'
56
+ version: '1.0'
54
57
  type: :runtime
55
58
  prerelease: false
56
59
  version_requirements: !ruby/object:Gem::Requirement
57
60
  none: false
58
61
  requirements:
59
- - - ~>
62
+ - - ! '>='
63
+ - !ruby/object:Gem::Version
64
+ version: 0.2.1
65
+ - - <
60
66
  - !ruby/object:Gem::Version
61
- version: '0.1'
67
+ version: '1.0'
62
68
  - !ruby/object:Gem::Dependency
63
69
  name: bundler
64
70
  requirement: !ruby/object:Gem::Requirement
@@ -148,7 +154,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
148
154
  version: '0'
149
155
  segments:
150
156
  - 0
151
- hash: -1688140956597634074
157
+ hash: -129850521152093868
152
158
  required_rubygems_version: !ruby/object:Gem::Requirement
153
159
  none: false
154
160
  requirements:
@@ -157,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
163
  version: '0'
158
164
  segments:
159
165
  - 0
160
- hash: -1688140956597634074
166
+ hash: -129850521152093868
161
167
  requirements: []
162
168
  rubyforge_project:
163
169
  rubygems_version: 1.8.23