diff options
Diffstat (limited to 'examples/test_config.rb')
-rw-r--r-- | examples/test_config.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/examples/test_config.rb b/examples/test_config.rb new file mode 100644 index 0000000..b5a1418 --- /dev/null +++ b/examples/test_config.rb @@ -0,0 +1,33 @@ +require 'yaml' + +class TestConfig + def initialize(collector, config) + @collector = collector + @config = config + @config.merge!(Longboat::Config.for_raider do + opt :test_config, "Config file for test_config", type: String + end) + + @name = "configurable_value" + @config_file = {} + @config_file = YAML.load_file(@config[:test_config]) if @config[:test_config] + end + + def raid + # Clean up any previously reported metrics + # to prevent stale labelsets + @collector.redact!(@name) + + # Report new metrics + value = @config_file["configurable_value"] || 4 + @collector.report!( + @name, + value, + help: "A value specified on the command line at runtime", + type: "gauge", + labels: { + given: @config[:test_config_given] ? 1 : 0 + } + ) + end +end |