(POOLER-160) Add Prometheus Stats Feeds

Add a new Prometheus class as an additional stats feed along with the
existing feeds.

Move the metrics initialisation code into its own class and sub-class
the individual metrics implementations under this.
This commit is contained in:
John O'Connor 2020-04-15 11:59:10 +01:00
parent c6ab52372a
commit ffab7def9e
9 changed files with 585 additions and 16 deletions

24
lib/vmpooler/metrics.rb Normal file
View file

@ -0,0 +1,24 @@
# frozen_string_literal: true
module Vmpooler
class Metrics
# static class instantiate appropriate metrics object.
def self.init(params)
if params[:statsd]
metrics = Vmpooler::Statsd.new(params[:statsd])
elsif params[:graphite]
metrics = Vmpooler::Graphite.new(params[:graphite])
elsif params[:prometheus]
metrics = Vmpooler::Promstats.new(params[:prometheus])
else
metrics = Vmpooler::DummyStatsd.new
end
metrics
end
end
end
require 'vmpooler/metrics/statsd'
require 'vmpooler/metrics/dummy_statsd'
require 'vmpooler/metrics/graphite'
require 'vmpooler/metrics/promstats'