Class: Prometheus::Client::Rack::Exporter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ Exporter

Returns a new instance of Exporter.



9
10
11
12
13
# File 'lib/prometheus/client/rack/exporter.rb', line 9

def initialize(app, options = {})
  @app = app
  @registry = options[:registry] || Client.registry
  @path = options[:path] || '/metrics.json'
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



7
8
9
# File 'lib/prometheus/client/rack/exporter.rb', line 7

def app
  @app
end

#pathObject (readonly)

Returns the value of attribute path.



7
8
9
# File 'lib/prometheus/client/rack/exporter.rb', line 7

def path
  @path
end

#registryObject (readonly)

Returns the value of attribute registry.



7
8
9
# File 'lib/prometheus/client/rack/exporter.rb', line 7

def registry
  @registry
end

Instance Method Details

#call(env) ⇒ Object



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

def call(env)
  if env['PATH_INFO'] == @path
    metrics_response
  else
    @app.call(env)
  end
end