Class: PhobosPrometheus::CountersValidator
- Inherits:
-
Object
- Object
- PhobosPrometheus::CountersValidator
- Includes:
- Logger
- Defined in:
- lib/phobos_prometheus/config_parser.rb
Overview
Validate Counters
Constant Summary collapse
- COUNTER_INSTRUMENTATION_MISSING =
'Missing required key :instrumentation for counter'- COUNTER_INVALID_KEY =
'Invalid configuration option detected at counter level, ignoring'- COUNTER_KEYS =
[:instrumentation].freeze
Instance Method Summary collapse
-
#initialize(counters) ⇒ CountersValidator
constructor
A new instance of CountersValidator.
- #validate ⇒ Object
- #validate_counter(counter) ⇒ Object
Methods included from Logger
#log_error, #log_info, #log_warn
Constructor Details
#initialize(counters) ⇒ CountersValidator
Returns a new instance of CountersValidator.
11 12 13 |
# File 'lib/phobos_prometheus/config_parser.rb', line 11 def initialize(counters) @counters = counters end |
Instance Method Details
#validate ⇒ Object
15 16 17 18 19 |
# File 'lib/phobos_prometheus/config_parser.rb', line 15 def validate @counters.map do |counter| validate_counter(counter) end end |
#validate_counter(counter) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/phobos_prometheus/config_parser.rb', line 21 def validate_counter(counter) Helper.assert_required_key(counter, :instrumentation) || \ Helper.fail_config(COUNTER_INSTRUMENTATION_MISSING) Helper.check_invalid_keys(COUNTER_KEYS, counter) || \ log_warn(COUNTER_INVALID_KEY) end |