Class: Periskop::Rack::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/periskop/rack/middleware.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Middleware.



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/periskop/rack/middleware.rb', line 10

def initialize(app, options = {})
  @app = app
  @pushgateway_address = options.fetch(:pushgateway_address)
  options[:collector] ||= Periskop::Client::ExceptionCollector.new
  @collector = options.fetch(:collector)

  @exporter =
    if @pushgateway_address
      @exporter = Periskop::Client::Exporter.new(@collector)
    end
end

Instance Attribute Details

#collectorObject

Returns the value of attribute collector.



8
9
10
# File 'lib/periskop/rack/middleware.rb', line 8

def collector
  @collector
end

Instance Method Details

#call(env) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/periskop/rack/middleware.rb', line 22

def call(env)
  begin
    response = @app.call(env)
  rescue Exception => ex
    report_push(env, ex)
    raise(ex)
  end

  maybe_ex = framework_exception(env)
  report_push(env, maybe_ex) if maybe_ex

  response
end