qless 0.10.2 → 0.10.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/qless-stats +108 -0
- data/lib/qless/version.rb +1 -1
- metadata +20 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2aefe62cf34864662a68ef488a8b654b90b5654
|
4
|
+
data.tar.gz: 8838c1771b595da7d1b7044b374763ecf6690d26
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bf3a2f150016910f64f42481cb02dd1b2330e721ce9e6646693da078e0d22853b7b0d71af7c0bc08e64e96cda28eaaaeeef5b331ceffe847c576744dd9a3a32
|
7
|
+
data.tar.gz: b6eb4d8bb30b09d1836cc66ddd4c88d00c49cace8397f8426cec9f295681868c6bad2aea38c53ef4294c624800077d01367b72e405f4f8bc06e41eb68939b747
|
data/exe/qless-stats
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'qless'
|
4
|
+
require 'statsd'
|
5
|
+
require 'thor'
|
6
|
+
|
7
|
+
class Stats < Thor
|
8
|
+
|
9
|
+
class_option :redis, :default => 'redis://localhost:6379/0'
|
10
|
+
class_option :interval, :type => :numeric, :default => 60,
|
11
|
+
:desc => 'Interval (in seconds) between stats collections'
|
12
|
+
class_option :count, :type => :numeric, :default => 0,
|
13
|
+
:desc => 'Number of collections to perform; <= 0 cycles forever'
|
14
|
+
|
15
|
+
no_commands do
|
16
|
+
def qless
|
17
|
+
if @qless.nil?
|
18
|
+
@qless = Qless::Client.new(url: options[:redis])
|
19
|
+
end
|
20
|
+
@qless
|
21
|
+
end
|
22
|
+
|
23
|
+
def counter(count=0)
|
24
|
+
if count > 0 then
|
25
|
+
return count.times
|
26
|
+
else
|
27
|
+
return Enumerator.new do |enum|
|
28
|
+
index = 0
|
29
|
+
while true do
|
30
|
+
enum << index
|
31
|
+
index += 1
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def periodically(count, interval)
|
38
|
+
start = Time.now.to_f
|
39
|
+
counter(count).each do |index|
|
40
|
+
target = start + interval * index
|
41
|
+
delay = [target - Time.now.to_f, 0].max
|
42
|
+
sleep(delay)
|
43
|
+
|
44
|
+
yield index
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
desc 'statsd', 'Emit metrics to statsd'
|
50
|
+
option :host, :type => :string, :default => 'localhost',
|
51
|
+
:desc => 'Statsd host.'
|
52
|
+
option :port, :type => :numeric, :default => 8125,
|
53
|
+
:desc => 'Statsd port.'
|
54
|
+
option :namespace, :type => :string, :default => nil,
|
55
|
+
:desc => 'Namespace for all metrics.'
|
56
|
+
option :postfix, :type => :string, :default => nil,
|
57
|
+
:desc => 'Postfix for all metrics.'
|
58
|
+
def statsd
|
59
|
+
client = Statsd.new(options[:host], options[:port]).tap do |c|
|
60
|
+
if not options[:namespace].nil?
|
61
|
+
c.namespace = options[:namespace]
|
62
|
+
end
|
63
|
+
|
64
|
+
if not options[:postfix].nil?
|
65
|
+
c.postfix = options[:postfix]
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
periodically(options[:count].to_i, options[:interval]) do
|
70
|
+
# Track per-queue information
|
71
|
+
qless.queues.counts.each do |counts|
|
72
|
+
queue = counts.delete('name')
|
73
|
+
|
74
|
+
# Counts of jobs in each state in this queue
|
75
|
+
counts['paused'] = counts['paused'] ? 1 : 0
|
76
|
+
counts.each do |key, value|
|
77
|
+
client.gauge "queues.#{queue}.#{key}", value
|
78
|
+
end
|
79
|
+
|
80
|
+
# Counts of completed / popped jobs and timing information
|
81
|
+
stats = qless.queues[queue].stats
|
82
|
+
client.gauge "queues.#{queue}.completed", stats['run']['count']
|
83
|
+
client.gauge "queues.#{queue}.popped", stats['wait']['count']
|
84
|
+
client.gauge "queues.#{queue}.failed", stats['failed']
|
85
|
+
client.gauge "queues.#{queue}.failures", stats['failures']
|
86
|
+
client.gauge "queues.#{queue}.retries", stats['retries']
|
87
|
+
|
88
|
+
['run', 'wait'].each do |type|
|
89
|
+
client.gauge "queues.#{queue}.#{type}.avg", stats[type]['mean']
|
90
|
+
client.gauge "queues.#{queue}.#{type}.std-dev", stats[type]['std']
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# Track failures
|
95
|
+
total = qless.jobs.failed.map do |failure, count|
|
96
|
+
client.gauge "failures.#{failure}", count
|
97
|
+
count
|
98
|
+
end.reduce(0, :+)
|
99
|
+
client.gauge 'failures', total
|
100
|
+
|
101
|
+
# Track workers
|
102
|
+
client.gauge 'workers', qless.workers.counts.length
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
|
108
|
+
Stats.start(ARGV)
|
data/lib/qless/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qless
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Lecocq
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-04-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: metriks
|
@@ -73,14 +73,28 @@ dependencies:
|
|
73
73
|
requirements:
|
74
74
|
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: 1.3
|
76
|
+
version: '1.3'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
81
|
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: 1.3
|
83
|
+
version: '1.3'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: statsd-ruby
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '1.3'
|
91
|
+
type: :runtime
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '1.3'
|
84
98
|
- !ruby/object:Gem::Dependency
|
85
99
|
name: thin
|
86
100
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,6 +150,7 @@ email:
|
|
136
150
|
executables:
|
137
151
|
- qless-web
|
138
152
|
- qless-config
|
153
|
+
- qless-stats
|
139
154
|
extensions: []
|
140
155
|
extra_rdoc_files: []
|
141
156
|
files:
|
@@ -145,6 +160,7 @@ files:
|
|
145
160
|
- Rakefile
|
146
161
|
- exe/install_phantomjs
|
147
162
|
- exe/qless-config
|
163
|
+
- exe/qless-stats
|
148
164
|
- exe/qless-web
|
149
165
|
- lib/qless.rb
|
150
166
|
- lib/qless/config.rb
|