Ensure nodes are consistent for usage stats

This commit updates vm usage stats collection to replace all instances of '.' characters within node strings. Without this change the node string containing a '.' character causes the metric to be interpreted as containing another node.
This commit is contained in:
kirby@puppetlabs.com 2018-12-19 12:45:50 -08:00
parent b4dfbca40e
commit 2de4a6db0b
3 changed files with 46 additions and 4 deletions

View file

@ -333,12 +333,13 @@ module Vmpooler
poolname = $redis.hget("vmpooler__vm__#{vm}", "template")
unless jenkins_build_url
user = user.gsub('.', '_')
$metrics.increment("usage.#{user}.#{poolname}")
return
end
url_parts = jenkins_build_url.split('/')[2..-1]
instance = url_parts[0].gsub('.', '_')
instance = url_parts[0]
value_stream_parts = url_parts[2].split('_')
value_stream = value_stream_parts.shift
branch = value_stream_parts.pop
@ -360,6 +361,7 @@ module Vmpooler
]
metric_parts = metric_parts.reject { |s| s.nil? }
metric_parts = metric_parts.map { |s| s.gsub('.', '_') }
$metrics.increment(metric_parts.join('.'))
rescue => err