Class: Resque::CloudWatch::Metrics
- Inherits:
-
Object
- Object
- Resque::CloudWatch::Metrics
show all
- Defined in:
- lib/resque/cloudwatch/metrics.rb,
lib/resque/cloudwatch/metrics/metric.rb,
lib/resque/cloudwatch/metrics/version.rb
Defined Under Namespace
Classes: Dimensions, Metric
Constant Summary
collapse
- DEFAULT_CW_NAMESPACE =
'Resque'
- MAX_METRIC_DATA_PER_PUT =
20
- VERSION =
'0.2.0'
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(redis: nil, redis_namespace: nil, interval: nil, cw_namespace: DEFAULT_CW_NAMESPACE) ⇒ Metrics
Returns a new instance of Metrics.
43
44
45
46
47
48
49
50
51
|
# File 'lib/resque/cloudwatch/metrics.rb', line 43
def initialize(redis: nil,
redis_namespace: nil,
interval: nil,
cw_namespace: DEFAULT_CW_NAMESPACE)
Resque.redis = redis if redis
@redis_namespace = redis_namespace
@interval = interval
@cw_namespace = cw_namespace
end
|
Class Method Details
.parse_arguments(args) ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/resque/cloudwatch/metrics.rb', line 22
def parse_arguments(args)
options = {}
redis = {}
opt = OptionParser.new
opt.on('-h', '--host <host>') { |v| redis[:host] = v }
opt.on('-p', '--port <port>') { |v| redis[:port] = v }
opt.on('-s', '--socket <socket>') { |v| redis[:path] = v }
opt.on('-a', '--password <password>') { |v| redis[:password] = v }
opt.on('-n', '--db <db>') { |v| redis[:db] = v }
opt.on('--url <url>') { |v| options[:redis] = v }
opt.on('--redis-namespace <namespace>') { |v| options[:redis_namespace] = v }
opt.on('--cw-namespace <namespace>') { |v| options[:cw_namespace] = v }
opt.on('-i', '--interval <interval>') { |v| options[:interval] = v.to_f }
opt.parse(args)
options[:redis] ||= redis unless redis.empty?
options
end
|
.run(args) ⇒ Object
18
19
20
|
# File 'lib/resque/cloudwatch/metrics.rb', line 18
def run(args)
new(parse_arguments(args)).run
end
|
Instance Method Details
#run ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/resque/cloudwatch/metrics.rb', line 53
def run
if @interval
loop do
thread = Thread.start { run_once }
thread.abort_on_exception = true
sleep @interval
end
else
run_once
end
end
|