Class: Prometheus::Client::Rack::Collector

Inherits:
Object
  • Object
show all
Defined in:
lib/prometheus/client/rack/collector.rb

Overview

Collector is a Rack middleware that provides a sample implementation of a HTTP tracer. The default label builder can be modified to export a different set of labels per recorded metric.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}, &label_builder) ⇒ Collector

Returns a new instance of Collector.


14
15
16
17
18
19
20
21
# File 'lib/prometheus/client/rack/collector.rb', line 14

def initialize(app, options = {}, &label_builder)
  @app = app
  @registry = options[:registry] || Client.registry
  @label_builder = label_builder || DEFAULT_LABEL_BUILDER

  init_request_metrics
  init_exception_metrics
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app


12
13
14
# File 'lib/prometheus/client/rack/collector.rb', line 12

def app
  @app
end

#registryObject (readonly)

Returns the value of attribute registry


12
13
14
# File 'lib/prometheus/client/rack/collector.rb', line 12

def registry
  @registry
end

Instance Method Details

#call(env) ⇒ Object

:nodoc:


23
24
25
# File 'lib/prometheus/client/rack/collector.rb', line 23

def call(env) # :nodoc:
  trace(env) { @app.call(env) }
end