debian-mirror-gitlab/lib/gitlab/metrics/rack_middleware.rb

29 lines
583 B
Ruby
Raw Normal View History

2019-02-15 15:39:39 +05:30
# frozen_string_literal: true
module Gitlab
module Metrics
# Rack middleware for tracking Rails and Grape requests.
class RackMiddleware
def initialize(app)
@app = app
end
# env - A Hash containing Rack environment details.
def call(env)
2020-10-24 23:57:45 +05:30
trans = WebTransaction.new(env)
begin
retval = trans.run { @app.call(env) }
2016-09-13 17:45:13 +05:30
rescue Exception => error # rubocop: disable Lint/RescueException
trans.add_event(:rails_exception)
raise error
end
retval
end
end
end
end