-
Notifications
You must be signed in to change notification settings - Fork 103
/
config.ru
32 lines (27 loc) · 1 KB
/
config.ru
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# frozen_string_literal: true
# This file is used by Rack-based servers to start the application.
require_relative "config/environment"
prometheus_enabled = ENV.fetch("PROMETHEUS_ENABLED", "false")
if prometheus_enabled == "true"
require "prometheus/middleware/collector"
rackapp = Rack::Builder.app do
use Prometheus::Middleware::Collector
if ENV["PROMETHEUS_BASIC_AUTH_USERNAME"].present?
map "/metrics" do
use Rack::Auth::Basic, "Ciao Prometheus Metrics" do |username, password|
Rack::Utils.secure_compare(ENV["PROMETHEUS_BASIC_AUTH_USERNAME"], username) &&
Rack::Utils.secure_compare(ENV["PROMETHEUS_BASIC_AUTH_PASSWORD"], password)
end
use Rack::Deflater
use Yabeda::Prometheus::Exporter, path: ""
run ->(_) { [500, {"Content-Type" => "text/html"}, ["Ciao Prometheus Metrics unreachable."]] }
end
else
use Yabeda::Prometheus::Exporter
end
run Rails.application
end
run rackapp
else
run Rails.application
end