Class: PhobosPrometheus::GaugesValidator
- Inherits:
-
Object
- Object
- PhobosPrometheus::GaugesValidator
- Includes:
- Logger
- Defined in:
- lib/phobos_prometheus/config_parser.rb
Overview
Validate gauges
Constant Summary collapse
- GAUGE_LABEL_MISSING =
'Missing required key :label for gauge'- GAUGE_INCREMENT_MISSING =
'Missing required key :increment for gauge'- GAUGE_DECREMENT_MISSING =
'Missing required key :decrement for gauge'- GAUGE_INVALID_KEY =
'Invalid configuration option detected at gauge level, ignoring'- GAUGE_KEYS =
[:label, :increment, :decrement].freeze
Instance Method Summary collapse
-
#initialize(gauges) ⇒ GaugesValidator
constructor
A new instance of GaugesValidator.
- #validate ⇒ Object
- #validate_gauge(gauge) ⇒ Object
Methods included from Logger
#log_error, #log_info, #log_warn
Constructor Details
#initialize(gauges) ⇒ GaugesValidator
Returns a new instance of GaugesValidator.
101 102 103 |
# File 'lib/phobos_prometheus/config_parser.rb', line 101 def initialize(gauges) @gauges = gauges end |
Instance Method Details
#validate ⇒ Object
105 106 107 108 109 |
# File 'lib/phobos_prometheus/config_parser.rb', line 105 def validate @gauges.map do |gauge| validate_gauge(gauge) end end |
#validate_gauge(gauge) ⇒ Object
111 112 113 114 115 116 117 |
# File 'lib/phobos_prometheus/config_parser.rb', line 111 def validate_gauge(gauge) Helper.assert_required_key(gauge, :label) || Helper.fail_config(GAUGE_LABEL_MISSING) Helper.assert_required_key(gauge, :increment) || Helper.fail_config(GAUGE_INCREMENT_MISSING) Helper.assert_required_key(gauge, :decrement) || Helper.fail_config(GAUGE_DECREMENT_MISSING) Helper.check_invalid_keys(GAUGE_KEYS, gauge) || \ log_warn(GAUGE_INVALID_KEY) end |