Class: RedisPrometheus::Collector
- Inherits:
-
Object
- Object
- RedisPrometheus::Collector
- Defined in:
- lib/redis_prometheus/collector.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Collector
constructor
A new instance of Collector.
- #register(&block) ⇒ Object
- #stats ⇒ Object
Constructor Details
#initialize ⇒ Collector
Returns a new instance of Collector.
8 9 10 |
# File 'lib/redis_prometheus/collector.rb', line 8 def initialize @collectors = [] end |
Class Method Details
.current ⇒ Object
3 4 5 6 |
# File 'lib/redis_prometheus/collector.rb', line 3 def self.current @current ||= self.new @current end |
Instance Method Details
#register(&block) ⇒ Object
24 25 26 |
# File 'lib/redis_prometheus/collector.rb', line 24 def register(&block) @collectors << block end |
#stats ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/redis_prometheus/collector.rb', line 12 def stats out = "" @collectors.each do |collector| ret = collector.call out << "# TYPE #{ret[:label]} #{ret[:type]}\n" out << "# HELP #{ret[:label]} #{ret[:description]}.\n" out << "#{ret[:label]}{service=\"#{ENV["REDIS_PROMETHEUS_SERVICE"]}\"} #{ret[:data]}\n" end out end |