Class: Sentry::Rack::CaptureExceptions
- Inherits:
-
Object
- Object
- Sentry::Rack::CaptureExceptions
- Defined in:
- lib/sentry/rack/capture_exceptions.rb
Constant Summary collapse
- ERROR_EVENT_ID_KEY =
"sentry.error_event_id"
- MECHANISM_TYPE =
"rack"
- SPAN_ORIGIN =
"auto.http.rack"
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.
10 11 12 |
# File 'lib/sentry/rack/capture_exceptions.rb', line 10 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
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 44 45 46 47 48 |
# File 'lib/sentry/rack/capture_exceptions.rb', line 14 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| Sentry.with_session_tracking do scope. scope.set_transaction_name(env["PATH_INFO"], source: :url) if env["PATH_INFO"] scope.set_rack_env(env) transaction = start_transaction(env, scope) scope.set_span(transaction) if transaction begin response = @app.call(env) rescue Sentry::Error finish_transaction(transaction, 500) raise # Don't capture Sentry errors rescue Exception => e capture_exception(e, env) finish_transaction(transaction, 500) raise end exception = collect_exception(env) capture_exception(exception, env) if exception finish_transaction(transaction, response[0]) response end end end |