mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-27 10:28:41 -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::V1
|
||||
|
||||
def configure(config, redis, environment = :production)
|
||||
def configure(config, redis, statsd, environment = :production)
|
||||
self.settings.set :config, config
|
||||
self.settings.set :redis, redis
|
||||
self.settings.set :statsd, statsd
|
||||
self.settings.set :environment, environment
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,16 @@ module Vmpooler
|
|||
Vmpooler::API.settings.redis
|
||||
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
|
||||
Vmpooler::API.settings.config[:config]
|
||||
end
|
||||
|
|
@ -79,6 +89,12 @@ module Vmpooler
|
|||
result['ok'] = false
|
||||
end
|
||||
|
||||
if result['ok']
|
||||
statsd.increment(statsd_prefix + '.checkout_success.' + template, 1)
|
||||
else
|
||||
statsd.increment(statsd_prefix + '.checkout_fail.' + template, 1)
|
||||
end
|
||||
|
||||
result
|
||||
end
|
||||
|
||||
|
|
@ -366,6 +382,10 @@ module Vmpooler
|
|||
result['domain'] = config['domain']
|
||||
end
|
||||
|
||||
if !result['ok']
|
||||
statsd.increment(statsd_prefix + '.checkout_fail.' + key, 1)
|
||||
end
|
||||
|
||||
JSON.pretty_generate(result)
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue