Class: Datadog::RackMiddleware
- Inherits:
-
Object
- Object
- Datadog::RackMiddleware
- Defined in:
- lib/datadog/rack_middleware.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, logger, opt = {}) ⇒ RackMiddleware
constructor
A new instance of RackMiddleware.
Constructor Details
#initialize(app, logger, opt = {}) ⇒ RackMiddleware
Returns a new instance of RackMiddleware.
19 20 21 22 23 |
# File 'lib/datadog/rack_middleware.rb', line 19 def initialize(app, logger, opt = {}) @app = app @logger = logger @raise_exceptions = opt.fetch(:raise_exceptions, false) end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
17 18 19 |
# File 'lib/datadog/rack_middleware.rb', line 17 def app @app end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
17 18 19 |
# File 'lib/datadog/rack_middleware.rb', line 17 def logger @logger end |
Instance Method Details
#call(env) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/datadog/rack_middleware.rb', line 25 def call(env) request = Rack::Request.new(env) start_time = Time.now status, headers, body = if @raise_exceptions app.call(env) else safely_process_request(env) end end_time = Time.now log_request(request, env, status, headers, start_time, end_time) [status, headers, body] rescue StandardError => e handle_exception(e) end |