Class: Gitlab::Metrics::RackMiddleware

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/metrics/rack_middleware.rb

Overview

Rack middleware for tracking Rails and Grape requests.

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ RackMiddleware

Returns a new instance of RackMiddleware.


7
8
9
# File 'lib/gitlab/metrics/rack_middleware.rb', line 7

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object

env - A Hash containing Rack environment details.


12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/gitlab/metrics/rack_middleware.rb', line 12

def call(env)
  trans = WebTransaction.new(env)

  begin
    retval = trans.run { @app.call(env) }

  rescue Exception => error # rubocop: disable Lint/RescueException
    trans.add_event(:rails_exception)

    raise error
  end

  retval
end