sentry-rails 5.23.0 → 5.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/sentry/rails/active_job.rb +55 -8
- data/lib/sentry/rails/configuration.rb +7 -3
- data/lib/sentry/rails/railtie.rb +5 -0
- data/lib/sentry/rails/tracing/action_controller_subscriber.rb +1 -1
- data/lib/sentry/rails/tracing/active_storage_subscriber.rb +4 -1
- data/lib/sentry/rails/version.rb +1 -1
- data/sentry-rails.gemspec +1 -1
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c15eae4b0c41144ee4cb68d4e291a33ac37d8ab0373b509a9a04578adb76cca
|
4
|
+
data.tar.gz: ef7cd4138884bcb785afc73c5e7276ad97a69976f220160fdd1f090fd0319496
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a89c4ff40235a704ed0beb92f8f2810f7466ca53897e0c24e851198d1a70d11b4a2cee245cfe9acc43165198d7642fc358a256be3db3e361c4cbd24178cb8a44
|
7
|
+
data.tar.gz: 4de89a962252b9ad7cb6b6d94d604367ab86bec25fe4a36526dc62bb509d28ee2acdbdeb7897b61868c1f7878315fe9137edb04a14aa48257eb71976b1da4350
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "set"
|
4
|
+
|
3
5
|
module Sentry
|
4
6
|
module Rails
|
5
7
|
module ActiveJobExtensions
|
@@ -21,6 +23,10 @@ module Sentry
|
|
21
23
|
OP_NAME = "queue.active_job"
|
22
24
|
SPAN_ORIGIN = "auto.queue.active_job"
|
23
25
|
|
26
|
+
EVENT_HANDLERS = {
|
27
|
+
"enqueue_retry.active_job" => :retry_handler
|
28
|
+
}
|
29
|
+
|
24
30
|
class << self
|
25
31
|
def record(job, &block)
|
26
32
|
Sentry.with_scope do |scope|
|
@@ -46,19 +52,54 @@ module Sentry
|
|
46
52
|
rescue Exception => e # rubocop:disable Lint/RescueException
|
47
53
|
finish_sentry_transaction(transaction, 500)
|
48
54
|
|
49
|
-
|
50
|
-
|
51
|
-
extra: sentry_context(job),
|
52
|
-
tags: {
|
53
|
-
job_id: job.job_id,
|
54
|
-
provider_job_id: job.provider_job_id
|
55
|
-
}
|
56
|
-
)
|
55
|
+
capture_exception(job, e)
|
56
|
+
|
57
57
|
raise
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
+
def capture_exception(job, e)
|
63
|
+
Sentry::Rails.capture_exception(
|
64
|
+
e,
|
65
|
+
extra: sentry_context(job),
|
66
|
+
tags: {
|
67
|
+
job_id: job.job_id,
|
68
|
+
provider_job_id: job.provider_job_id
|
69
|
+
}
|
70
|
+
)
|
71
|
+
end
|
72
|
+
|
73
|
+
def register_event_handlers
|
74
|
+
EVENT_HANDLERS.each do |name, handler|
|
75
|
+
subscribers << ActiveSupport::Notifications.subscribe(name) do |*args|
|
76
|
+
public_send(handler, *args)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def detach_event_handlers
|
82
|
+
subscribers.each do |subscriber|
|
83
|
+
ActiveSupport::Notifications.unsubscribe(subscriber)
|
84
|
+
end
|
85
|
+
subscribers.clear
|
86
|
+
end
|
87
|
+
|
88
|
+
# This handler does not capture error unless `active_job_report_on_retry_error` is true
|
89
|
+
def retry_handler(*args)
|
90
|
+
handle_error_event(*args) do |job, error|
|
91
|
+
return if !Sentry.initialized? || job.already_supported_by_sentry_integration?
|
92
|
+
return unless Sentry.configuration.rails.active_job_report_on_retry_error
|
93
|
+
|
94
|
+
capture_exception(job, error)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def handle_error_event(*args)
|
99
|
+
event = ActiveSupport::Notifications::Event.new(*args)
|
100
|
+
yield(event.payload[:job], event.payload[:error])
|
101
|
+
end
|
102
|
+
|
62
103
|
def finish_sentry_transaction(transaction, status)
|
63
104
|
return unless transaction
|
64
105
|
|
@@ -95,6 +136,12 @@ module Sentry
|
|
95
136
|
argument
|
96
137
|
end
|
97
138
|
end
|
139
|
+
|
140
|
+
private
|
141
|
+
|
142
|
+
def subscribers
|
143
|
+
@__subscribers__ ||= Set.new
|
144
|
+
end
|
98
145
|
end
|
99
146
|
end
|
100
147
|
end
|
@@ -17,12 +17,12 @@ module Sentry
|
|
17
17
|
if ::Rails.logger
|
18
18
|
if defined?(::ActiveSupport::BroadcastLogger) && ::Rails.logger.is_a?(::ActiveSupport::BroadcastLogger)
|
19
19
|
dupped_broadcasts = ::Rails.logger.broadcasts.map(&:dup)
|
20
|
-
|
20
|
+
self.sdk_logger = ::ActiveSupport::BroadcastLogger.new(*dupped_broadcasts)
|
21
21
|
else
|
22
|
-
|
22
|
+
self.sdk_logger = ::Rails.logger.dup
|
23
23
|
end
|
24
24
|
else
|
25
|
-
|
25
|
+
sdk_logger.warn(Sentry::LOGGER_PROGNAME) do
|
26
26
|
<<~MSG
|
27
27
|
sentry-rails can't detect Rails.logger. it may be caused by misplacement of the SDK initialization code
|
28
28
|
please make sure you place the Sentry.init block under the `config/initializers` folder, e.g. `config/initializers/sentry.rb`
|
@@ -156,6 +156,9 @@ module Sentry
|
|
156
156
|
# @return [Hash<String, Array<Symbol>>]
|
157
157
|
attr_accessor :active_support_logger_subscription_items
|
158
158
|
|
159
|
+
# Set this option to true if you want Sentry to capture each retry failure
|
160
|
+
attr_accessor :active_job_report_on_retry_error
|
161
|
+
|
159
162
|
def initialize
|
160
163
|
@register_error_subscriber = false
|
161
164
|
@report_rescued_exceptions = true
|
@@ -172,6 +175,7 @@ module Sentry
|
|
172
175
|
@enable_db_query_source = true
|
173
176
|
@db_query_source_threshold_ms = 100
|
174
177
|
@active_support_logger_subscription_items = Sentry::Rails::ACTIVE_SUPPORT_LOGGER_SUBSCRIPTION_ITEMS_DEFAULT.dup
|
178
|
+
@active_job_report_on_retry_error = false
|
175
179
|
end
|
176
180
|
end
|
177
181
|
end
|
data/lib/sentry/rails/railtie.rb
CHANGED
@@ -51,6 +51,11 @@ module Sentry
|
|
51
51
|
activate_tracing
|
52
52
|
|
53
53
|
register_error_subscriber(app) if ::Rails.version.to_f >= 7.0 && Sentry.configuration.rails.register_error_subscriber
|
54
|
+
|
55
|
+
# Presence of ActiveJob is no longer a reliable cue
|
56
|
+
if defined?(Sentry::Rails::ActiveJobExtensions)
|
57
|
+
Sentry::Rails::ActiveJobExtensions::SentryReporter.register_event_handlers
|
58
|
+
end
|
54
59
|
end
|
55
60
|
|
56
61
|
runner do
|
@@ -14,7 +14,7 @@ module Sentry
|
|
14
14
|
SPAN_ORIGIN = "auto.view.rails"
|
15
15
|
|
16
16
|
def self.subscribe!
|
17
|
-
Sentry.
|
17
|
+
Sentry.sdk_logger.warn <<~MSG
|
18
18
|
DEPRECATION WARNING: sentry-rails has changed its approach on controller span recording and #{self.name} is now depreacted.
|
19
19
|
Please stop using or referencing #{self.name} as it will be removed in the next major release.
|
20
20
|
MSG
|
@@ -33,7 +33,10 @@ module Sentry
|
|
33
33
|
duration: duration
|
34
34
|
) do |span|
|
35
35
|
payload.each do |key, value|
|
36
|
-
|
36
|
+
next if key == START_TIMESTAMP_NAME
|
37
|
+
next if key == :key && !Sentry.configuration.send_default_pii
|
38
|
+
|
39
|
+
span.set_data(key, value)
|
37
40
|
end
|
38
41
|
end
|
39
42
|
end
|
data/lib/sentry/rails/version.rb
CHANGED
data/sentry-rails.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sentry-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.24.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sentry Team
|
8
8
|
bindir: exe
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: railties
|
@@ -29,21 +29,21 @@ dependencies:
|
|
29
29
|
requirements:
|
30
30
|
- - "~>"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 5.
|
32
|
+
version: 5.24.0
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: 5.
|
39
|
+
version: 5.24.0
|
40
40
|
description: A gem that provides Rails integration for the Sentry error logger
|
41
41
|
email: accounts@sentry.io
|
42
42
|
executables: []
|
43
43
|
extensions: []
|
44
44
|
extra_rdoc_files:
|
45
|
-
- README.md
|
46
45
|
- LICENSE.txt
|
46
|
+
- README.md
|
47
47
|
files:
|
48
48
|
- ".gitignore"
|
49
49
|
- ".rspec"
|
@@ -84,15 +84,15 @@ files:
|
|
84
84
|
- lib/sentry/rails/tracing/active_support_subscriber.rb
|
85
85
|
- lib/sentry/rails/version.rb
|
86
86
|
- sentry-rails.gemspec
|
87
|
-
homepage: https://github.com/getsentry/sentry-ruby/tree/5.
|
87
|
+
homepage: https://github.com/getsentry/sentry-ruby/tree/5.24.0/sentry-rails
|
88
88
|
licenses:
|
89
89
|
- MIT
|
90
90
|
metadata:
|
91
|
-
homepage_uri: https://github.com/getsentry/sentry-ruby/tree/5.
|
92
|
-
source_code_uri: https://github.com/getsentry/sentry-ruby/tree/5.
|
93
|
-
changelog_uri: https://github.com/getsentry/sentry-ruby/blob/5.
|
91
|
+
homepage_uri: https://github.com/getsentry/sentry-ruby/tree/5.24.0/sentry-rails
|
92
|
+
source_code_uri: https://github.com/getsentry/sentry-ruby/tree/5.24.0/sentry-rails
|
93
|
+
changelog_uri: https://github.com/getsentry/sentry-ruby/blob/5.24.0/CHANGELOG.md
|
94
94
|
bug_tracker_uri: https://github.com/getsentry/sentry-ruby/issues
|
95
|
-
documentation_uri: http://www.rubydoc.info/gems/sentry-rails/5.
|
95
|
+
documentation_uri: http://www.rubydoc.info/gems/sentry-rails/5.24.0
|
96
96
|
rdoc_options: []
|
97
97
|
require_paths:
|
98
98
|
- lib
|
@@ -107,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
107
|
- !ruby/object:Gem::Version
|
108
108
|
version: '0'
|
109
109
|
requirements: []
|
110
|
-
rubygems_version: 3.6.
|
110
|
+
rubygems_version: 3.6.7
|
111
111
|
specification_version: 4
|
112
112
|
summary: A gem that provides Rails integration for the Sentry error logger
|
113
113
|
test_files: []
|