Class: Prometheus::Client::Rack::Exporter
- Inherits:
-
Object
- Object
- Prometheus::Client::Rack::Exporter
- Defined in:
- lib/prometheus/client/rack/exporter.rb
Overview
Exporter is a Rack middleware that provides a sample implementation of a HTTP tracer. The default label builder can be modified to export a differet set of labels per recorded metric.
Constant Summary collapse
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#registry ⇒ Object
readonly
Returns the value of attribute registry.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Exporter
constructor
A new instance of Exporter.
Constructor Details
#initialize(app, options = {}) ⇒ Exporter
Returns a new instance of Exporter.
19 20 21 22 23 24 |
# File 'lib/prometheus/client/rack/exporter.rb', line 19 def initialize(app, = {}) @app = app @registry = [:registry] || Client.registry @path = [:path] || '/metrics' @acceptable = build_dictionary(FORMATS, FALLBACK) end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
14 15 16 |
# File 'lib/prometheus/client/rack/exporter.rb', line 14 def app @app end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
14 15 16 |
# File 'lib/prometheus/client/rack/exporter.rb', line 14 def path @path end |
#registry ⇒ Object (readonly)
Returns the value of attribute registry.
14 15 16 |
# File 'lib/prometheus/client/rack/exporter.rb', line 14 def registry @registry end |
Instance Method Details
#call(env) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/prometheus/client/rack/exporter.rb', line 26 def call(env) if env['PATH_INFO'] == @path format = negotiate(env['HTTP_ACCEPT'], @acceptable) format ? respond_with(format) : not_acceptable(FORMATS) else @app.call(env) end end |