sentry-rails 7.1.0 → 7.3.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/Gemfile +5 -0
- data/README.md +5 -1
- data/gemfiles/ruby-2.7_rails-5.2.0.gemfile.lock +17 -17
- data/gemfiles/ruby-2.7_rails-6.0.0.gemfile.lock +17 -17
- data/gemfiles/ruby-2.7_rails-6.1.0.gemfile.lock +17 -17
- data/gemfiles/ruby-2.7_rails-7.0.0.gemfile.lock +17 -17
- data/gemfiles/ruby-2.7_rails-7.1.0.gemfile.lock +18 -18
- data/gemfiles/ruby-3.0_rails-6.1.0.gemfile.lock +34 -20
- data/gemfiles/ruby-3.0_rails-7.0.0.gemfile.lock +34 -20
- data/gemfiles/ruby-3.0_rails-7.1.0.gemfile.lock +34 -20
- data/gemfiles/ruby-3.1_rails-6.1.0.gemfile.lock +62 -38
- data/gemfiles/ruby-3.1_rails-7.0.0.gemfile.lock +62 -38
- data/gemfiles/ruby-3.1_rails-7.1.0.gemfile.lock +62 -38
- data/gemfiles/ruby-3.1_rails-7.2.0.gemfile.lock +129 -105
- data/gemfiles/ruby-3.2_rails-6.1.0.gemfile.lock +96 -72
- data/gemfiles/ruby-3.2_rails-7.0.0.gemfile.lock +96 -72
- data/gemfiles/ruby-3.2_rails-7.1.0.gemfile.lock +98 -74
- data/gemfiles/ruby-3.2_rails-7.2.0.gemfile.lock +95 -71
- data/gemfiles/ruby-3.2_rails-8.0.0.gemfile.lock +169 -145
- data/gemfiles/ruby-3.3_rails-6.1.0.gemfile.lock +96 -72
- data/gemfiles/ruby-3.3_rails-7.0.0.gemfile.lock +96 -72
- data/gemfiles/ruby-3.3_rails-7.1.0.gemfile.lock +98 -74
- data/gemfiles/ruby-3.3_rails-7.2.0.gemfile.lock +95 -71
- data/gemfiles/ruby-3.3_rails-8.0.0.gemfile.lock +169 -145
- data/gemfiles/ruby-3.4_rails-7.1.0.gemfile.lock +80 -64
- data/gemfiles/ruby-3.4_rails-7.2.0.gemfile.lock +77 -61
- data/gemfiles/ruby-3.4_rails-8.0.0.gemfile.lock +151 -135
- data/gemfiles/ruby-3.4_rails-8.1.3.gemfile.lock +151 -135
- data/gemfiles/ruby-4.0_rails-6.1.0.gemfile.lock +78 -62
- data/gemfiles/ruby-4.0_rails-7.0.0.gemfile.lock +78 -62
- data/gemfiles/ruby-4.0_rails-7.1.0.gemfile.lock +80 -64
- data/gemfiles/ruby-4.0_rails-8.0.0.gemfile.lock +151 -135
- data/gemfiles/ruby-4.0_rails-8.1.3.gemfile.lock +151 -135
- data/gemfiles/ruby-jruby-9.4.14.0_rails-6.1.0.gemfile.lock +35 -35
- data/gemfiles/ruby-jruby-9.4.14.0_rails-7.0.0.gemfile.lock +35 -35
- data/gemfiles/ruby-jruby-9.4.14.0_rails-7.1.0.gemfile.lock +35 -35
- data/lib/sentry/rails/active_job.rb +46 -186
- data/lib/sentry/rails/active_job_extension.rb +196 -0
- data/lib/sentry/rails/configuration.rb +12 -0
- data/lib/sentry/rails/good_job_cron.rb +152 -0
- data/lib/sentry/rails/overrides/streaming_reporter.rb +2 -0
- data/lib/sentry/rails/railtie.rb +15 -1
- data/lib/sentry/rails/solid_queue_recurring.rb +119 -0
- data/lib/sentry/rails/version.rb +1 -1
- data/lib/sentry/rails.rb +47 -0
- data/sentry-rails.gemspec +1 -1
- metadata +11 -9
- data/bin/test_old +0 -389
data/lib/sentry/rails/railtie.rb
CHANGED
|
@@ -6,6 +6,11 @@ require "sentry/rails/backtrace_cleaner"
|
|
|
6
6
|
|
|
7
7
|
module Sentry
|
|
8
8
|
class Railtie < ::Rails::Railtie
|
|
9
|
+
# Referencing ActionController::Live loads ActionDispatch::Response, and Rails
|
|
10
|
+
# warns when that happens before the application has initialized. Rails 8.1.4
|
|
11
|
+
# added the :action_controller_live load hook so we can wait for it instead.
|
|
12
|
+
SUPPORTS_ACTION_CONTROLLER_LIVE_LOAD_HOOK = Gem::Version.new(::Rails.version) >= Gem::Version.new("8.1.4")
|
|
13
|
+
|
|
9
14
|
# middlewares can't be injected after initialize
|
|
10
15
|
initializer "sentry.use_rack_middleware" do |app|
|
|
11
16
|
# placed after all the file-sending middlewares so we can avoid unnecessary transactions
|
|
@@ -99,7 +104,16 @@ module Sentry
|
|
|
99
104
|
ActiveSupport.on_load :action_controller do
|
|
100
105
|
include Sentry::Rails::ControllerMethods
|
|
101
106
|
include Sentry::Rails::ControllerTransaction
|
|
102
|
-
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
if SUPPORTS_ACTION_CONTROLLER_LIVE_LOAD_HOOK
|
|
110
|
+
ActiveSupport.on_load :action_controller_live do
|
|
111
|
+
prepend Sentry::Rails::Overrides::StreamingReporter
|
|
112
|
+
end
|
|
113
|
+
else
|
|
114
|
+
ActiveSupport.on_load :action_controller do
|
|
115
|
+
ActionController::Live.send(:prepend, Sentry::Rails::Overrides::StreamingReporter)
|
|
116
|
+
end
|
|
103
117
|
end
|
|
104
118
|
end
|
|
105
119
|
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Sentry
|
|
4
|
+
module Rails
|
|
5
|
+
# Sends Crons check-ins for Solid Queue recurring tasks.
|
|
6
|
+
# Enable with `config.enabled_patches << :solid_queue_recurring`.
|
|
7
|
+
module SolidQueueRecurring
|
|
8
|
+
PAYLOAD_KEY = "_sentry_recurring_task"
|
|
9
|
+
CURRENT_TASK = :sentry_solid_queue_recurring_task
|
|
10
|
+
|
|
11
|
+
module RecurringTask
|
|
12
|
+
def enqueue(at:)
|
|
13
|
+
Thread.current[CURRENT_TASK] = self unless Sentry::Rails::SolidQueueRecurring.excluded?(self)
|
|
14
|
+
super
|
|
15
|
+
ensure
|
|
16
|
+
Thread.current[CURRENT_TASK] = nil
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
module Job
|
|
21
|
+
def serialize
|
|
22
|
+
@_sentry_recurring_task ||= Sentry::Rails::SolidQueueRecurring.monitor_for(Thread.current[CURRENT_TASK], self)
|
|
23
|
+
payload = super
|
|
24
|
+
payload[PAYLOAD_KEY] = @_sentry_recurring_task if @_sentry_recurring_task
|
|
25
|
+
payload
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def deserialize(job_data)
|
|
29
|
+
super
|
|
30
|
+
@_sentry_recurring_task = job_data[PAYLOAD_KEY]
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
class << self
|
|
35
|
+
def excluded?(task)
|
|
36
|
+
return false unless Sentry.initialized?
|
|
37
|
+
|
|
38
|
+
Array(Sentry.configuration.rails.solid_queue_exclude_recurring_tasks).any? { |pattern| pattern === task.key.to_s }
|
|
39
|
+
rescue StandardError => e
|
|
40
|
+
Sentry.sdk_logger.error(Sentry::LOGGER_PROGNAME) { "Could not check solid_queue_exclude_recurring_tasks for #{task.key}: #{e.class}: #{e.message}" }
|
|
41
|
+
false
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Runs in the scheduler, which is where Solid Queue evaluates the schedule.
|
|
45
|
+
def monitor_for(task, job)
|
|
46
|
+
return unless task && Sentry.initialized?
|
|
47
|
+
job_class = task.class_name.present? ? task.class_name.safe_constantize : task.class.default_job_class
|
|
48
|
+
return unless job.instance_of?(job_class)
|
|
49
|
+
return if job_class < Sentry::Cron::MonitorCheckIns::Patch
|
|
50
|
+
|
|
51
|
+
slug = Sentry::Cron::Slug.from(task.key)
|
|
52
|
+
return unless slug
|
|
53
|
+
|
|
54
|
+
config = Sentry::Cron::FugitSchedule.from_cron(cron_for(task))
|
|
55
|
+
return unless config
|
|
56
|
+
|
|
57
|
+
{ "slug" => slug, "crontab" => config.schedule.value, "timezone" => config.timezone }.compact
|
|
58
|
+
rescue StandardError => e
|
|
59
|
+
Sentry.sdk_logger.error(Sentry::LOGGER_PROGNAME) { "Not monitoring Solid Queue recurring task #{task.key}: #{e.class}: #{e.message}" }
|
|
60
|
+
nil
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def perform(job)
|
|
64
|
+
data = job.instance_variable_get(:@_sentry_recurring_task)
|
|
65
|
+
return yield unless data && Sentry.initialized?
|
|
66
|
+
|
|
67
|
+
return yield unless data["crontab"]
|
|
68
|
+
|
|
69
|
+
cron_config = Sentry.configuration.cron
|
|
70
|
+
monitor_config = Sentry::Cron::MonitorConfig.from_crontab(
|
|
71
|
+
data["crontab"],
|
|
72
|
+
timezone: data["timezone"],
|
|
73
|
+
checkin_margin: cron_config.default_checkin_margin,
|
|
74
|
+
max_runtime: cron_config.default_max_runtime
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
Sentry::Cron::MonitorCheckIns.with_check_in(data["slug"], monitor_config: monitor_config) { yield }
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def patch
|
|
81
|
+
return if @patched
|
|
82
|
+
|
|
83
|
+
@patched = true
|
|
84
|
+
ActiveSupport.on_load(:active_job) do
|
|
85
|
+
prepend Sentry::Rails::SolidQueueRecurring::Job
|
|
86
|
+
around_perform { |job, block| Sentry::Rails::SolidQueueRecurring.perform(job, &block) }
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
apply = proc do
|
|
90
|
+
if defined?(::SolidQueue::RecurringTask) && !(::SolidQueue::RecurringTask < Sentry::Rails::SolidQueueRecurring::RecurringTask)
|
|
91
|
+
::SolidQueue::RecurringTask.prepend(Sentry::Rails::SolidQueueRecurring::RecurringTask)
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
::Rails.application.reloader.to_prepare(&apply)
|
|
95
|
+
apply.call if ::Rails.application.initialized?
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
private
|
|
99
|
+
|
|
100
|
+
# Mirrors RecurringTask, which applies SolidQueue.time_zone to zoneless schedules.
|
|
101
|
+
def cron_for(task)
|
|
102
|
+
cron = ::Fugit.parse(task.schedule)
|
|
103
|
+
zone = ::SolidQueue.time_zone if ::SolidQueue.respond_to?(:time_zone)
|
|
104
|
+
return cron unless cron.is_a?(::Fugit::Cron) && cron.zone.nil? && zone.present?
|
|
105
|
+
|
|
106
|
+
::Fugit.parse("#{cron.to_cron_s} #{zone}")
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
Sentry.register_patch(:solid_queue_recurring) do |config|
|
|
114
|
+
if defined?(::SolidQueue) && defined?(::Rails.application) && ::Rails.application
|
|
115
|
+
Sentry::Rails::SolidQueueRecurring.patch
|
|
116
|
+
else
|
|
117
|
+
config.sdk_logger.warn(Sentry::LOGGER_PROGNAME) { "You tried to enable the Solid Queue recurring task integration but the `solid_queue` gem was not detected." }
|
|
118
|
+
end
|
|
119
|
+
end
|
data/lib/sentry/rails/version.rb
CHANGED
data/lib/sentry/rails.rb
CHANGED
|
@@ -5,13 +5,60 @@ require "sentry-ruby"
|
|
|
5
5
|
require "sentry/integrable"
|
|
6
6
|
require "sentry/rails/tracing"
|
|
7
7
|
require "sentry/rails/configuration"
|
|
8
|
+
require "sentry/rails/active_job_extension"
|
|
8
9
|
require "sentry/rails/structured_logging"
|
|
9
10
|
require "sentry/rails/engine"
|
|
10
11
|
require "sentry/rails/railtie"
|
|
12
|
+
require "sentry/rails/good_job_cron"
|
|
13
|
+
require "sentry/rails/solid_queue_recurring"
|
|
11
14
|
|
|
12
15
|
module Sentry
|
|
13
16
|
module Rails
|
|
14
17
|
extend Integrable
|
|
15
18
|
register_integration name: "rails", version: Sentry::Rails::VERSION
|
|
19
|
+
|
|
20
|
+
DEFAULT_ACTIVE_JOB_EXTENSION = ActiveJobExtension.new
|
|
21
|
+
private_constant :DEFAULT_ACTIVE_JOB_EXTENSION
|
|
22
|
+
|
|
23
|
+
# Returns whether sentry-rails reports ActiveJob jobs run through the given
|
|
24
|
+
# queue adapter, in which case the backend gem should not report them itself.
|
|
25
|
+
# The result depends on the current configuration, so check it when a job is
|
|
26
|
+
# handled rather than caching it.
|
|
27
|
+
#
|
|
28
|
+
# @param adapter_class_name [String, Class]
|
|
29
|
+
# @return [Boolean]
|
|
30
|
+
def self.active_job_owns_adapter?(adapter_class_name)
|
|
31
|
+
Sentry.initialized? && !Sentry.configuration.rails.skippable_job_adapters.include?(adapter_class_name.to_s)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Registers the extension for ActiveJob jobs run through the given queue
|
|
35
|
+
# adapter. Raises ArgumentError if it is not an {ActiveJobExtension}.
|
|
36
|
+
#
|
|
37
|
+
# @param adapter [Symbol] the adapter name, such as `:sidekiq`
|
|
38
|
+
# @param extension [ActiveJobExtension]
|
|
39
|
+
# @return [ActiveJobExtension]
|
|
40
|
+
def self.register_active_job_extension(adapter, extension)
|
|
41
|
+
unless extension.is_a?(ActiveJobExtension)
|
|
42
|
+
raise ArgumentError, "ActiveJob extension must be an instance of #{ActiveJobExtension}, got #{extension.inspect}"
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
active_job_extensions[adapter.to_sym] = extension
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Returns the extension for the job class' queue adapter, or the default
|
|
49
|
+
# {ActiveJobExtension} when none is registered.
|
|
50
|
+
#
|
|
51
|
+
# @param job_class [Class]
|
|
52
|
+
# @return [ActiveJobExtension]
|
|
53
|
+
def self.active_job_extension_for(job_class)
|
|
54
|
+
active_job_extensions.fetch(ActiveJobExtension.adapter_name(job_class), DEFAULT_ACTIVE_JOB_EXTENSION)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Returns the registered extensions by adapter name.
|
|
58
|
+
#
|
|
59
|
+
# @return [Hash{Symbol => ActiveJobExtension}]
|
|
60
|
+
def self.active_job_extensions
|
|
61
|
+
@active_job_extensions ||= {}
|
|
62
|
+
end
|
|
16
63
|
end
|
|
17
64
|
end
|
data/sentry-rails.gemspec
CHANGED
|
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
|
|
|
31
31
|
spec.require_paths = ["lib"]
|
|
32
32
|
|
|
33
33
|
spec.add_dependency "railties", ">= 5.2.0"
|
|
34
|
-
spec.add_dependency "sentry-ruby", "~> 7.
|
|
34
|
+
spec.add_dependency "sentry-ruby", "~> 7.3.0"
|
|
35
35
|
|
|
36
36
|
spec.post_install_message = <<~MSG
|
|
37
37
|
Starting with sentry-rails 7.1.0, Rails structured logging is disabled by default.
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sentry-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 7.
|
|
4
|
+
version: 7.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sentry Team
|
|
@@ -29,14 +29,14 @@ dependencies:
|
|
|
29
29
|
requirements:
|
|
30
30
|
- - "~>"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: 7.
|
|
32
|
+
version: 7.3.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: 7.
|
|
39
|
+
version: 7.3.0
|
|
40
40
|
description: A gem that provides Rails integration for the Sentry error logger
|
|
41
41
|
email: accounts@sentry.io
|
|
42
42
|
executables: []
|
|
@@ -57,7 +57,6 @@ files:
|
|
|
57
57
|
- bin/console
|
|
58
58
|
- bin/setup
|
|
59
59
|
- bin/test
|
|
60
|
-
- bin/test_old
|
|
61
60
|
- gemfiles/ruby-2.7_rails-5.2.0.gemfile.lock
|
|
62
61
|
- gemfiles/ruby-2.7_rails-6.0.0.gemfile.lock
|
|
63
62
|
- gemfiles/ruby-2.7_rails-6.1.0.gemfile.lock
|
|
@@ -97,6 +96,7 @@ files:
|
|
|
97
96
|
- lib/sentry/rails.rb
|
|
98
97
|
- lib/sentry/rails/action_cable.rb
|
|
99
98
|
- lib/sentry/rails/active_job.rb
|
|
99
|
+
- lib/sentry/rails/active_job_extension.rb
|
|
100
100
|
- lib/sentry/rails/background_worker.rb
|
|
101
101
|
- lib/sentry/rails/backtrace_cleaner.rb
|
|
102
102
|
- lib/sentry/rails/breadcrumb/active_support_logger.rb
|
|
@@ -107,6 +107,7 @@ files:
|
|
|
107
107
|
- lib/sentry/rails/engine.rb
|
|
108
108
|
- lib/sentry/rails/error_reporter_context.rb
|
|
109
109
|
- lib/sentry/rails/error_subscriber.rb
|
|
110
|
+
- lib/sentry/rails/good_job_cron.rb
|
|
110
111
|
- lib/sentry/rails/log_subscriber.rb
|
|
111
112
|
- lib/sentry/rails/log_subscribers/action_controller_subscriber.rb
|
|
112
113
|
- lib/sentry/rails/log_subscribers/action_mailer_subscriber.rb
|
|
@@ -116,6 +117,7 @@ files:
|
|
|
116
117
|
- lib/sentry/rails/railtie.rb
|
|
117
118
|
- lib/sentry/rails/rescued_exception_interceptor.rb
|
|
118
119
|
- lib/sentry/rails/serializer.rb
|
|
120
|
+
- lib/sentry/rails/solid_queue_recurring.rb
|
|
119
121
|
- lib/sentry/rails/structured_logging.rb
|
|
120
122
|
- lib/sentry/rails/tracing.rb
|
|
121
123
|
- lib/sentry/rails/tracing/abstract_subscriber.rb
|
|
@@ -125,15 +127,15 @@ files:
|
|
|
125
127
|
- lib/sentry/rails/tracing/active_support_subscriber.rb
|
|
126
128
|
- lib/sentry/rails/version.rb
|
|
127
129
|
- sentry-rails.gemspec
|
|
128
|
-
homepage: https://github.com/getsentry/sentry-ruby/tree/7.
|
|
130
|
+
homepage: https://github.com/getsentry/sentry-ruby/tree/7.3.0/sentry-rails
|
|
129
131
|
licenses:
|
|
130
132
|
- MIT
|
|
131
133
|
metadata:
|
|
132
|
-
homepage_uri: https://github.com/getsentry/sentry-ruby/tree/7.
|
|
133
|
-
source_code_uri: https://github.com/getsentry/sentry-ruby/tree/7.
|
|
134
|
-
changelog_uri: https://github.com/getsentry/sentry-ruby/blob/7.
|
|
134
|
+
homepage_uri: https://github.com/getsentry/sentry-ruby/tree/7.3.0/sentry-rails
|
|
135
|
+
source_code_uri: https://github.com/getsentry/sentry-ruby/tree/7.3.0/sentry-rails
|
|
136
|
+
changelog_uri: https://github.com/getsentry/sentry-ruby/blob/7.3.0/CHANGELOG.md
|
|
135
137
|
bug_tracker_uri: https://github.com/getsentry/sentry-ruby/issues
|
|
136
|
-
documentation_uri: http://www.rubydoc.info/gems/sentry-rails/7.
|
|
138
|
+
documentation_uri: http://www.rubydoc.info/gems/sentry-rails/7.3.0
|
|
137
139
|
post_install_message: |
|
|
138
140
|
Starting with sentry-rails 7.1.0, Rails structured logging is disabled by default.
|
|
139
141
|
Set `config.rails.structured_logging.enabled = true` to enable it.
|