sentry-rails 5.1.0 → 5.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/Gemfile +1 -0
- data/lib/sentry/rails/active_job.rb +62 -58
- data/lib/sentry/rails/error_subscriber.rb +0 -9
- data/lib/sentry/rails/version.rb +1 -1
- data/sentry-rails.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8abb9b42e0bad172e91125577c9e675687a6b4a2b1a905c83258fcbc1b1b4402
|
4
|
+
data.tar.gz: '095d6e8fbc545a88ecc6ec0d4a8e2cd046e0d1cfa4816e13cfa5b1f40b656d5d'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84fdcf91056c8502fa63880a0d456e3677adafa15c7df35c7a1949249623d07c0217fa9286c3edda6ce7f1dcb0f096f48f25bbb54555e598124f67652b168576
|
7
|
+
data.tar.gz: e91d36c193548d10575a3e45c1023c1eb4d7628ded62f604d1659fd9589a5f5ed450592bc3d50ea64fbdc8517385ab439d547e80e8031382e8120b5f3af7dd25
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -5,76 +5,80 @@ module Sentry
|
|
5
5
|
if !Sentry.initialized? || already_supported_by_sentry_integration?
|
6
6
|
super
|
7
7
|
else
|
8
|
-
|
9
|
-
|
10
|
-
super
|
11
|
-
end
|
8
|
+
SentryReporter.record(self) do
|
9
|
+
super
|
12
10
|
end
|
13
11
|
end
|
14
12
|
end
|
15
13
|
|
16
|
-
def
|
17
|
-
|
18
|
-
|
19
|
-
if is_a?(::Sentry::SendEventJob)
|
20
|
-
nil
|
21
|
-
else
|
22
|
-
Sentry.start_transaction(name: scope.transaction_name, op: "active_job")
|
23
|
-
end
|
24
|
-
|
25
|
-
scope.set_span(transaction) if transaction
|
26
|
-
|
27
|
-
return_value = block.call
|
14
|
+
def already_supported_by_sentry_integration?
|
15
|
+
Sentry.configuration.rails.skippable_job_adapters.include?(self.class.queue_adapter.class.to_s)
|
16
|
+
end
|
28
17
|
|
29
|
-
|
18
|
+
class SentryReporter
|
19
|
+
class << self
|
20
|
+
def record(job, &block)
|
21
|
+
Sentry.with_scope do |scope|
|
22
|
+
begin
|
23
|
+
scope.set_transaction_name(job.class.name)
|
24
|
+
transaction =
|
25
|
+
if job.is_a?(::Sentry::SendEventJob)
|
26
|
+
nil
|
27
|
+
else
|
28
|
+
Sentry.start_transaction(name: scope.transaction_name, op: "active_job")
|
29
|
+
end
|
30
30
|
|
31
|
-
|
32
|
-
rescue Exception => e # rubocop:disable Lint/RescueException
|
33
|
-
finish_sentry_transaction(transaction, 500)
|
31
|
+
scope.set_span(transaction) if transaction
|
34
32
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
provider_job_id: provider_job_id
|
41
|
-
}
|
42
|
-
)
|
43
|
-
raise e
|
44
|
-
end
|
33
|
+
yield.tap do
|
34
|
+
finish_sentry_transaction(transaction, 200)
|
35
|
+
end
|
36
|
+
rescue Exception => e # rubocop:disable Lint/RescueException
|
37
|
+
finish_sentry_transaction(transaction, 500)
|
45
38
|
|
46
|
-
|
47
|
-
|
39
|
+
Sentry::Rails.capture_exception(
|
40
|
+
e,
|
41
|
+
extra: sentry_context(job),
|
42
|
+
tags: {
|
43
|
+
job_id: job.job_id,
|
44
|
+
provider_job_id: job.provider_job_id
|
45
|
+
}
|
46
|
+
)
|
47
|
+
raise
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
48
51
|
|
49
|
-
|
50
|
-
|
51
|
-
end
|
52
|
+
def finish_sentry_transaction(transaction, status)
|
53
|
+
return unless transaction
|
52
54
|
|
53
|
-
|
54
|
-
|
55
|
-
|
55
|
+
transaction.set_http_status(status)
|
56
|
+
transaction.finish
|
57
|
+
end
|
56
58
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
59
|
+
def sentry_context(job)
|
60
|
+
{
|
61
|
+
active_job: job.class.name,
|
62
|
+
arguments: sentry_serialize_arguments(job.arguments),
|
63
|
+
scheduled_at: job.scheduled_at,
|
64
|
+
job_id: job.job_id,
|
65
|
+
provider_job_id: job.provider_job_id,
|
66
|
+
locale: job.locale
|
67
|
+
}
|
68
|
+
end
|
67
69
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
70
|
+
def sentry_serialize_arguments(argument)
|
71
|
+
case argument
|
72
|
+
when Hash
|
73
|
+
argument.transform_values { |v| sentry_serialize_arguments(v) }
|
74
|
+
when Array, Enumerable
|
75
|
+
argument.map { |v| sentry_serialize_arguments(v) }
|
76
|
+
when ->(v) { v.respond_to?(:to_global_id) }
|
77
|
+
argument.to_global_id.to_s rescue argument
|
78
|
+
else
|
79
|
+
argument
|
80
|
+
end
|
81
|
+
end
|
78
82
|
end
|
79
83
|
end
|
80
84
|
end
|
@@ -4,15 +4,6 @@ module Sentry
|
|
4
4
|
# See https://github.com/rails/rails/blob/main/activesupport/lib/active_support/error_reporter.rb for more information.
|
5
5
|
class ErrorSubscriber
|
6
6
|
def report(error, handled:, severity:, context:)
|
7
|
-
# a component may already have an integration to capture exceptions while its operation is also wrapped inside an `app.executor.wrap` (e.g. ActionCable)
|
8
|
-
# in such condition, the exception would be captured repeatedly. it usually happens in this order:
|
9
|
-
#
|
10
|
-
# 1. exception captured and reported by the component integration and re-raised
|
11
|
-
# 2. exception captured by the executor, which then reports it with executor.error_reporter
|
12
|
-
#
|
13
|
-
# and because there's no direct communication between the 2 callbacks, we need a way to identify if an exception has been captured before
|
14
|
-
# using a Sentry-specific intance variable should be the last impactful way
|
15
|
-
return if error.instance_variable_get(:@__sentry_captured)
|
16
7
|
Sentry::Rails.capture_exception(error, level: severity, contexts: { "rails.error" => context }, tags: { handled: handled })
|
17
8
|
end
|
18
9
|
end
|
data/lib/sentry/rails/version.rb
CHANGED
data/sentry-rails.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sentry-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.1
|
4
|
+
version: 5.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sentry Team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 5.1
|
33
|
+
version: 5.2.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 5.1
|
40
|
+
version: 5.2.1
|
41
41
|
description: A gem that provides Rails integration for the Sentry error logger
|
42
42
|
email: accounts@sentry.io
|
43
43
|
executables: []
|