collective-metrics 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Collectfile +1 -0
- data/Gemfile +1 -0
- data/README.md +38 -5
- data/lib/collective.rb +5 -3
- data/lib/collective/collectors/memcached.rb +21 -0
- data/lib/collective/version.rb +1 -1
- metadata +5 -4
data/Collectfile
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,23 +1,56 @@
|
|
1
1
|
# Collective
|
2
2
|
|
3
|
-
It collects metrics
|
3
|
+
It collects metrics from various services/systems and outputs them to STDOUT
|
4
|
+
using the [l2met log convetions](https://github.com/ryandotsmith/l2met/wiki/Usage#logging-convention).
|
5
|
+
|
6
|
+
```
|
7
|
+
source=erics_mac_book_pro.local measure.redis.used_memory=1.02
|
8
|
+
source=erics_mac_book_pro.local measure.redis.connected_clients=2
|
9
|
+
source=erics_mac_book_pro.local measure.sidekiq.queues.processed=1275
|
10
|
+
source=erics_mac_book_pro.local measure.sidekiq.queues.failed=128
|
11
|
+
source=erics_mac_book_pro.local measure.redis.blocked_clients=0
|
12
|
+
source=erics_mac_book_pro.local measure.redis.connected_slaves=0
|
13
|
+
source=erics_mac_book_pro.local measure.sidekiq.queues.enqueued=0
|
14
|
+
source=erics_mac_book_pro.local measure.sidekiq.workers.busy=0
|
15
|
+
```
|
16
|
+
|
17
|
+
## Collectors
|
18
|
+
|
19
|
+
It includes collectors for the following:
|
20
|
+
|
21
|
+
* Sidekiq
|
22
|
+
* Redis
|
23
|
+
* Memcached
|
4
24
|
|
5
25
|
## Installation
|
6
26
|
|
7
27
|
Add this line to your application's Gemfile:
|
8
28
|
|
9
|
-
|
29
|
+
```ruby
|
30
|
+
gem 'collective-metrics'
|
31
|
+
```
|
10
32
|
|
11
33
|
## Usage
|
12
34
|
|
13
35
|
Add a Collectfile:
|
14
36
|
|
37
|
+
```ruby
|
38
|
+
use Collective::Collectors::Sidekiq
|
39
|
+
use Collective::Collectors::Redis
|
40
|
+
use Collective::Collectors::Redis, url: ENV['ROLLOUT_REDIS_URL']
|
15
41
|
```
|
16
|
-
require 'collective/services/sidekiq'
|
17
|
-
```
|
18
42
|
|
43
|
+
Start the collectors.
|
44
|
+
|
45
|
+
```bash
|
46
|
+
$ collective start
|
19
47
|
```
|
20
|
-
|
48
|
+
|
49
|
+
If you're running this on heroku, just add a line to your Procfile:
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
web: bundle exec rackup
|
53
|
+
collector: bundle exec collective start
|
21
54
|
```
|
22
55
|
|
23
56
|
## Contributing
|
data/lib/collective.rb
CHANGED
@@ -8,16 +8,18 @@ module Collective
|
|
8
8
|
autoload :Builder, 'collective/builder'
|
9
9
|
|
10
10
|
module Collectors
|
11
|
-
autoload :Sidekiq,
|
12
|
-
autoload :Redis,
|
11
|
+
autoload :Sidekiq, 'collective/collectors/sidekiq'
|
12
|
+
autoload :Redis, 'collective/collectors/redis'
|
13
|
+
autoload :Memcached, 'collective/collectors/memcached'
|
13
14
|
end
|
14
15
|
|
15
16
|
class << self
|
16
17
|
def run
|
17
18
|
Metrics.subscribe
|
19
|
+
STDOUT.sync = true
|
18
20
|
|
19
21
|
builder = Builder.new
|
20
|
-
builder.instance_eval File.read('Collectfile')
|
22
|
+
builder.instance_eval File.read('Collectfile'), __FILE__, __LINE__ - 1
|
21
23
|
builder.run
|
22
24
|
end
|
23
25
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Collective::Collectors
|
2
|
+
class Memcached < Collective::Collector
|
3
|
+
requires :dalli
|
4
|
+
|
5
|
+
collect do
|
6
|
+
client.stats.each do |server, stats|
|
7
|
+
stats.each do |metric, value|
|
8
|
+
instrument "memcached.#{metric}", value, source: server
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def client
|
14
|
+
::Dalli::Client.new(url)
|
15
|
+
end
|
16
|
+
|
17
|
+
def url
|
18
|
+
options[:url] || ENV['MEMCACHED_URL']
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/collective/version.rb
CHANGED
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.
|
4
|
+
version: 0.1.1
|
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-
|
12
|
+
date: 2013-08-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rufus-scheduler
|
@@ -129,6 +129,7 @@ files:
|
|
129
129
|
- lib/collective/cli.rb
|
130
130
|
- lib/collective/collector.rb
|
131
131
|
- lib/collective/collector/dsl.rb
|
132
|
+
- lib/collective/collectors/memcached.rb
|
132
133
|
- lib/collective/collectors/redis.rb
|
133
134
|
- lib/collective/collectors/sidekiq.rb
|
134
135
|
- lib/collective/version.rb
|
@@ -147,7 +148,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
147
148
|
version: '0'
|
148
149
|
segments:
|
149
150
|
- 0
|
150
|
-
hash:
|
151
|
+
hash: -1688140956597634074
|
151
152
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
153
|
none: false
|
153
154
|
requirements:
|
@@ -156,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
157
|
version: '0'
|
157
158
|
segments:
|
158
159
|
- 0
|
159
|
-
hash:
|
160
|
+
hash: -1688140956597634074
|
160
161
|
requirements: []
|
161
162
|
rubyforge_project:
|
162
163
|
rubygems_version: 1.8.23
|