Class: Etna::MetricsExporter
- Inherits:
-
Object
- Object
- Etna::MetricsExporter
- Defined in:
- lib/etna/metrics.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
- #exporter ⇒ Object
-
#initialize(app, path: '/metrics') ⇒ MetricsExporter
constructor
A new instance of MetricsExporter.
Constructor Details
#initialize(app, path: '/metrics') ⇒ MetricsExporter
Returns a new instance of MetricsExporter.
4 5 6 7 |
# File 'lib/etna/metrics.rb', line 4 def initialize(app, path: '/metrics') @app = app @path = path end |
Instance Method Details
#call(env) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/etna/metrics.rb', line 18 def call(env) if env['PATH_INFO'] == @path exporter.call(env) else @app.call(env) end end |
#exporter ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/etna/metrics.rb', line 9 def exporter @exporter ||= begin exporter = Yabeda::Prometheus::Exporter.new(@app, path: @path) Rack::Auth::Basic.new(exporter) do |user, pw| user == 'prometheus' && pw == ENV['METRICS_PW'] end end end |