Class: LcpRuby::MetricsController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/lcp_ruby/metrics_controller.rb

Instance Method Summary collapse

Instance Method Details

#showObject



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'app/controllers/lcp_ruby/metrics_controller.rb', line 3

def show
  unless Metrics::PrometheusCheck.available?
    render plain: I18n.t("lcp_ruby.monitoring.prometheus_unavailable",
                         default: "Prometheus client not available"),
           status: :not_found
    return
  end

  Metrics::CollectorRegistry.collect_all

  output = ::Prometheus::Client::Formats::Text.marshal(::Prometheus::Client.registry)
  render plain: output, content_type: "text/plain; version=0.0.4; charset=utf-8"
end