Class: Upfluence::HTTP::Middleware::Prometheus
- Inherits:
-
Object
- Object
- Upfluence::HTTP::Middleware::Prometheus
- Defined in:
- lib/upfluence/http/middleware/prometheus.rb
Constant Summary collapse
- LABELS =
%i[path method env].freeze
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, registry = ::Prometheus::Client.registry) ⇒ Prometheus
constructor
A new instance of Prometheus.
Constructor Details
#initialize(app, registry = ::Prometheus::Client.registry) ⇒ Prometheus
Returns a new instance of Prometheus.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/upfluence/http/middleware/prometheus.rb', line 10 def initialize(app, registry = ::Prometheus::Client.registry) @registry = registry @request_total_count = @registry.get( :uhttp_handler_requests_total ) || @registry.counter( :uhttp_handler_requests_total, docstring: 'Histogram of processed items', labels: LABELS + %i[status] ) @request_histogram = @registry.get( :uhttp_handler_requests_duration_second ) || @registry.histogram( :uhttp_handler_requests_duration_second, docstring: 'Histogram of processing time', labels: LABELS ) @app = app end |
Instance Method Details
#call(env) ⇒ Object
32 33 34 |
# File 'lib/upfluence/http/middleware/prometheus.rb', line 32 def call(env) trace(env) { @app.call(env) } end |