Class: Gremlin::MetricsController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- Gremlin::MetricsController
- Defined in:
- app/controllers/gremlin/metrics_controller.rb
Instance Method Summary collapse
Instance Method Details
#index ⇒ Object
3 4 5 |
# File 'app/controllers/gremlin/metrics_controller.rb', line 3 def index render plain: marshal.join("\n") end |
#marshal ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'app/controllers/gremlin/metrics_controller.rb', line 7 def marshal registry = Gremlin.registry metrics = registry.metrics.map do |metric| metric.repr end plaintext(metrics) end |
#plaintext(metric_representations) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/controllers/gremlin/metrics_controller.rb', line 17 def plaintext(metric_representations) lines = [] metric_representations.each do |repr| lines << repr[:type] lines << repr[:help] # Prometheus expects metric labels to be of the format <label>="<label_value>" repr[:values].each do |labels, value| l = [] labels.each do |k,v| l << "#{k}=\"#{v}\"" end lines << "#{repr[:name].to_s}{#{l.join(',')}} #{value}" end end lines end |