mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-26 18:08:42 -05:00
(WIP) (RE-7014) Add tracking of gets
This adds the statsd tracking of pool gets. It is seemingly working on success, but not fail. WIP
This commit is contained in:
parent
500c6cc03c
commit
8d82258e4c
3 changed files with 27 additions and 2 deletions
|
|
@ -42,9 +42,10 @@ module Vmpooler
|
||||||
use Vmpooler::API::Reroute
|
use Vmpooler::API::Reroute
|
||||||
use Vmpooler::API::V1
|
use Vmpooler::API::V1
|
||||||
|
|
||||||
def configure(config, redis, environment = :production)
|
def configure(config, redis, statsd, environment = :production)
|
||||||
self.settings.set :config, config
|
self.settings.set :config, config
|
||||||
self.settings.set :redis, redis
|
self.settings.set :redis, redis
|
||||||
|
self.settings.set :statsd, statsd
|
||||||
self.settings.set :environment, environment
|
self.settings.set :environment, environment
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,16 @@ module Vmpooler
|
||||||
Vmpooler::API.settings.redis
|
Vmpooler::API.settings.redis
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def statsd
|
||||||
|
Vmpooler::API.settings.statsd
|
||||||
|
end
|
||||||
|
|
||||||
|
def statsd_prefix
|
||||||
|
if Vmpooler::API.settings.statsd
|
||||||
|
Vmpooler::API.settings.config[:statsd]['prefix']? Vmpooler::API.settings.config[:statsd]['prefix'] : 'vmpooler'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def config
|
def config
|
||||||
Vmpooler::API.settings.config[:config]
|
Vmpooler::API.settings.config[:config]
|
||||||
end
|
end
|
||||||
|
|
@ -79,6 +89,12 @@ module Vmpooler
|
||||||
result['ok'] = false
|
result['ok'] = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if result['ok']
|
||||||
|
statsd.increment(statsd_prefix + '.checkout_success.' + template, 1)
|
||||||
|
else
|
||||||
|
statsd.increment(statsd_prefix + '.checkout_fail.' + template, 1)
|
||||||
|
end
|
||||||
|
|
||||||
result
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -366,6 +382,10 @@ module Vmpooler
|
||||||
result['domain'] = config['domain']
|
result['domain'] = config['domain']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if !result['ok']
|
||||||
|
statsd.increment(statsd_prefix + '.checkout_fail.' + key, 1)
|
||||||
|
end
|
||||||
|
|
||||||
JSON.pretty_generate(result)
|
JSON.pretty_generate(result)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
6
vmpooler
6
vmpooler
|
|
@ -17,7 +17,11 @@ end
|
||||||
|
|
||||||
api = Thread.new {
|
api = Thread.new {
|
||||||
thr = Vmpooler::API.new
|
thr = Vmpooler::API.new
|
||||||
thr.helpers.configure(config, Vmpooler.new_redis(redis_host))
|
if statsd
|
||||||
|
thr.helpers.configure(config, Vmpooler.new_redis(redis_host), Vmpooler.new_statsd(statsd, statsd_port))
|
||||||
|
else
|
||||||
|
thr.helpers.configure(config, Vmpooler.new_redis(redis_host), statsd=nil)
|
||||||
|
end
|
||||||
thr.helpers.execute!
|
thr.helpers.execute!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue