collective-metrics 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/collective.gemspec +2 -0
- data/lib/collective.rb +1 -0
- data/lib/collective/collectors/rabbitmq.rb +67 -0
- data/lib/collective/version.rb +1 -1
- metadata +31 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b3b49dcb907693182c790ca003bb99a6def1c44
|
4
|
+
data.tar.gz: 4278d571b71de3944dc11520c9e5982156d88bef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9c6f6961708da103efb07f9fd05f27d6c4bbf5ab7814b5e38c0757d39c54192e893e25380b7ce06597ddf9d6dad2232a003024c99ffb4307f6c17130fcf544c
|
7
|
+
data.tar.gz: d5da8e93fe533bafd4f949464c7dc7bfaa1981a0beb6aa650c01789d3dc8b6a557e3bb2ac54f70d012fd747926b1f7c1044ffb9d49bc385d19b6a7b628e005d1
|
data/README.md
CHANGED
@@ -21,6 +21,7 @@ It includes collectors for the following:
|
|
21
21
|
* Sidekiq
|
22
22
|
* Redis
|
23
23
|
* Memcached
|
24
|
+
* RabbitMQ (You need to have the management plugin enabled)
|
24
25
|
|
25
26
|
## Installation
|
26
27
|
|
@@ -37,7 +38,7 @@ Add a Collectfile:
|
|
37
38
|
```ruby
|
38
39
|
use Collective::Collectors::Sidekiq
|
39
40
|
use Collective::Collectors::Redis
|
40
|
-
use Collective::Collectors::
|
41
|
+
use Collective::Collectors::RabbitMQ, url: ENV['RABBITMQ_MANAGEMENT_URL']
|
41
42
|
```
|
42
43
|
|
43
44
|
Start the collectors.
|
data/collective.gemspec
CHANGED
@@ -21,6 +21,8 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_dependency 'rufus-scheduler', '~> 2.0'
|
22
22
|
spec.add_dependency 'thor', '~> 0.18'
|
23
23
|
spec.add_dependency 'formatted-metrics', ['>= 0.2.1', '< 2.0']
|
24
|
+
spec.add_dependency 'faraday'
|
25
|
+
spec.add_dependency 'faraday_middleware'
|
24
26
|
|
25
27
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
26
28
|
spec.add_development_dependency 'rake'
|
data/lib/collective.rb
CHANGED
@@ -11,6 +11,7 @@ module Collective
|
|
11
11
|
autoload :Sidekiq, 'collective/collectors/sidekiq'
|
12
12
|
autoload :Redis, 'collective/collectors/redis'
|
13
13
|
autoload :Memcached, 'collective/collectors/memcached'
|
14
|
+
autoload :RabbitMQ, 'collective/collectors/rabbitmq'
|
14
15
|
end
|
15
16
|
|
16
17
|
class << self
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'pp'
|
2
|
+
|
3
|
+
module Collective::Collectors
|
4
|
+
class RabbitMQ < Collective::Collector
|
5
|
+
requires :faraday
|
6
|
+
requires :faraday_middleware
|
7
|
+
requires :json
|
8
|
+
|
9
|
+
collect do
|
10
|
+
instrument_overview
|
11
|
+
instrument_queues
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def instrument_overview
|
17
|
+
overview = client.get('overview').body
|
18
|
+
|
19
|
+
group 'rabbitmq' do |group|
|
20
|
+
%w[message_stats object_totals queue_totals].each do |key|
|
21
|
+
group.group key do |group|
|
22
|
+
instrument_hash(group, overview[key])
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def instrument_queues
|
29
|
+
queues = client.get('queues').body
|
30
|
+
|
31
|
+
group 'rabbitmq.queue' do |group|
|
32
|
+
queues.each do |queue|
|
33
|
+
instrument_hash(group, queue, source: "rabbitmq.queue.#{queue['name']}")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def instrument_hash(group, hash, options={})
|
39
|
+
hash.each do |key, val|
|
40
|
+
case val
|
41
|
+
when Hash
|
42
|
+
group.group key do |group|
|
43
|
+
instrument_hash(group, val, options)
|
44
|
+
end
|
45
|
+
else
|
46
|
+
group.instrument(key, val, options) if instrumentable?(val)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def instrumentable?(value)
|
52
|
+
Float(value) rescue nil
|
53
|
+
end
|
54
|
+
|
55
|
+
def client
|
56
|
+
@client ||= Faraday.new(url) do |builder|
|
57
|
+
builder.response :json, content_type: /\bjson$/
|
58
|
+
builder.adapter Faraday.default_adapter
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def url
|
63
|
+
options[:url]
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
data/lib/collective/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: collective-metrics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric J. Holmes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rufus-scheduler
|
@@ -58,6 +58,34 @@ dependencies:
|
|
58
58
|
- - <
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '2.0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: faraday
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
type: :runtime
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: faraday_middleware
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
type: :runtime
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
61
89
|
- !ruby/object:Gem::Dependency
|
62
90
|
name: bundler
|
63
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,6 +151,7 @@ files:
|
|
123
151
|
- lib/collective/collector.rb
|
124
152
|
- lib/collective/collector/dsl.rb
|
125
153
|
- lib/collective/collectors/memcached.rb
|
154
|
+
- lib/collective/collectors/rabbitmq.rb
|
126
155
|
- lib/collective/collectors/redis.rb
|
127
156
|
- lib/collective/collectors/sidekiq.rb
|
128
157
|
- lib/collective/version.rb
|