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?
Sentry.clone_hub_to_current_thread
Sentry.with_scope do |scope|
Sentry.with_session_tracking do
scope.clear_breadcrumbs
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
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
|