Class: Sentry::Rack::CaptureExceptions
- Defined in:
- lib/sentry/rack/capture_exceptions.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ CaptureExceptions
constructor
A new instance of CaptureExceptions.
Constructor Details
#initialize(app) ⇒ CaptureExceptions
Returns a new instance of CaptureExceptions.
4 5 6 |
# File 'lib/sentry/rack/capture_exceptions.rb', line 4 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/sentry/rack/capture_exceptions.rb', line 8 def call(env) return @app.call(env) unless Sentry.initialized? # make sure the current thread has a clean hub Sentry.clone_hub_to_current_thread Sentry.with_scope do |scope| scope. scope.set_transaction_name(env["PATH_INFO"]) if env["PATH_INFO"] scope.set_rack_env(env) sentry_trace = env["HTTP_SENTRY_TRACE"] span = Sentry::Transaction.from_sentry_trace(sentry_trace, name: scope.transaction_name, op: transaction_op) if sentry_trace span ||= Sentry.start_transaction(name: scope.transaction_name, op: transaction_op) scope.set_span(span) begin response = @app.call(env) rescue Sentry::Error finish_span(span, 500) raise # Don't capture Sentry errors rescue Exception => e capture_exception(e) finish_span(span, 500) raise end exception = collect_exception(env) capture_exception(exception) if exception finish_span(span, response[0]) response end end |