mirror of
https://github.com/puppetlabs/vmpooler.git
synced 2026-01-27 02:18:41 -05:00
[QENG-4075] Unify graphite and statsd for the pool manager
Prior to this, the `pool_manager.rb` library could take handles for both graphite and statsd endpoints (which were considered mutually exclusive), and then would use one. There was a bevy of conditional logic around sending metrics to the graphite/statsd handles (and actually at least one bug of omission). Here we refactor more, building on earlier work: - Our graphite class comes into line with the API of our Statsd and DummyStatsd classes - In `pool_manager.rb` we now accept a single "metrics" handle, and we drop all the conditional logic around statsd vs. graphite - We move the inconsistent error handling out of the calling classes and into our metrics classes, actually logging to `$stderr` when we can't publish metrics - We unify the setup code to use `config` to determine whether statsd, graphite, or a dummy metrics handle should be used, and make that happen. - Cleaned up some tests. We could probably stand to do a bit more work in this area.
This commit is contained in:
parent
f26e0f9bd7
commit
218f098800
6 changed files with 70 additions and 69 deletions
|
|
@ -54,10 +54,6 @@ module Vmpooler
|
|||
end
|
||||
end
|
||||
|
||||
if parsed_config[:graphite]['server']
|
||||
parsed_config[:graphite]['prefix'] ||= 'vmpooler'
|
||||
end
|
||||
|
||||
if parsed_config[:tagfilter]
|
||||
parsed_config[:tagfilter].keys.each do |tag|
|
||||
parsed_config[:tagfilter][tag] = Regexp.new(parsed_config[:tagfilter][tag])
|
||||
|
|
@ -65,7 +61,6 @@ module Vmpooler
|
|||
end
|
||||
|
||||
parsed_config[:uptime] = Time.now
|
||||
|
||||
parsed_config
|
||||
end
|
||||
|
||||
|
|
@ -77,19 +72,16 @@ module Vmpooler
|
|||
Vmpooler::Logger.new logfile
|
||||
end
|
||||
|
||||
def self.new_graphite(server)
|
||||
if server.nil? or server.empty? or server.length == 0
|
||||
nil
|
||||
def self.new_metrics(params)
|
||||
if config[:statsd]
|
||||
Vmpooler::Statsd.new(config[:statsd])
|
||||
elsif config[:graphite]
|
||||
Vmpooler::Graphite.new(config[:graphite])
|
||||
else
|
||||
Vmpooler::Graphite.new server
|
||||
Vmpooler::DummyStatsd.new
|
||||
end
|
||||
end
|
||||
|
||||
def self.new_statsd(params)
|
||||
return DummyStatsd.new unless params
|
||||
Statsd.new params
|
||||
end
|
||||
|
||||
def self.pools(conf)
|
||||
conf[:pools]
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue