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
22
# 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
  # The service name should be read from config or could be git repo name 
  @service_name = options[:service_name]
  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:



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

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