Class: Datadog::Contrib::Rails::ExceptionMiddleware
- Inherits:
-
Object
- Object
- Datadog::Contrib::Rails::ExceptionMiddleware
- Defined in:
- lib/ddtrace/contrib/rails/middlewares.rb
Overview
This is only here to catch errors, the Rack module does something very similar, however, since it’s not in the same place in the stack, when the Rack middleware is called, error is already swallowed and handled by Rails so we miss the call stack, for instance.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ ExceptionMiddleware
constructor
A new instance of ExceptionMiddleware.
Constructor Details
#initialize(app) ⇒ ExceptionMiddleware
Returns a new instance of ExceptionMiddleware.
11 12 13 |
# File 'lib/ddtrace/contrib/rails/middlewares.rb', line 11 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ddtrace/contrib/rails/middlewares.rb', line 15 def call(env) @app.call(env) # rubocop:disable Lint/RescueException # Here we really want to catch *any* exception, not only StandardError, # as we really have no clue of what is in the block, # and it is user code which should be executed no matter what. # It's not a problem since we re-raise it afterwards so for example a # SignalException::Interrupt would still bubble up. rescue Exception => e tracer = ::Rails.configuration.datadog_trace.fetch(:tracer) span = tracer.active_span() span.set_error(e) unless span.nil? raise e end |