sentry-rails 4.3.1 → 4.4.0.pre.beta.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.craft.yml +3 -2
- data/CHANGELOG.md +43 -0
- data/app/jobs/sentry/send_event_job.rb +5 -0
- data/lib/sentry/rails.rb +1 -0
- data/lib/sentry/rails/capture_exceptions.rb +7 -6
- data/lib/sentry/rails/configuration.rb +22 -1
- data/lib/sentry/rails/railtie.rb +12 -21
- data/lib/sentry/rails/rescued_exception_interceptor.rb +10 -1
- data/lib/sentry/rails/tracing.rb +9 -8
- data/lib/sentry/rails/tracing/action_controller_subscriber.rb +2 -0
- data/lib/sentry/rails/tracing/action_view_subscriber.rb +2 -0
- data/lib/sentry/rails/tracing/active_record_subscriber.rb +2 -0
- data/lib/sentry/rails/version.rb +1 -1
- data/sentry-rails.gemspec +2 -2
- metadata +8 -9
- data/lib/sentry/rails/overrides/file_handler.rb +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1abbd4e00c660384cf961b09d8d8a2d98148336adf9ed7b766f73ca24c08cf33
|
4
|
+
data.tar.gz: ca6bba663f5db7948e5078e77e38e7dbfb30bf9849c885fd5645a62e422bbb97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a05541ee2a1441ed70055b909d3c04b87b931df16c70e0c076d2ed44cda60146e1680c4326fb0e55a96dd598b1171cd4fcb6cbcaeab9110936c7a6a9048601b
|
7
|
+
data.tar.gz: 9374e863588b2a926c05b8e2e0ed295d46813d9ebae9b98061e1dcc6329cb2ffcd3c617f66ef77e2c171e5a30c401fbefde0beed2717d382289bf2c161649fb2
|
data/.craft.yml
CHANGED
@@ -11,9 +11,10 @@ artifactProvider:
|
|
11
11
|
name: github
|
12
12
|
targets:
|
13
13
|
- name: gem
|
14
|
-
- name: github
|
15
|
-
tagPrefix: sentry-rails-v
|
16
14
|
- name: registry
|
17
15
|
type: sdk
|
18
16
|
config:
|
19
17
|
canonical: 'gem:sentry-rails'
|
18
|
+
- name: github
|
19
|
+
tagPrefix: sentry-rails-v
|
20
|
+
changelog: sentry-rails/CHANGELOG.md
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,48 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 4.4.0-beta.0
|
4
|
+
|
5
|
+
### Features
|
6
|
+
|
7
|
+
- Make tracing subscribers configurable [#1344](https://github.com/getsentry/sentry-ruby/pull/1344)
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
# current default:
|
11
|
+
# - Sentry::Rails::Tracing::ActionControllerSubscriber
|
12
|
+
# - Sentry::Rails::Tracing::ActionViewSubscriber
|
13
|
+
# - Sentry::Rails::Tracing::ActiveRecordSubscriber
|
14
|
+
|
15
|
+
# you can add a new subscriber
|
16
|
+
config.rails.tracing_subscribers << MySubscriber
|
17
|
+
# or replace the set completely
|
18
|
+
config.rails.tracing_subscribers = [MySubscriber]
|
19
|
+
```
|
20
|
+
|
21
|
+
### Bug Fixes
|
22
|
+
|
23
|
+
- Report exceptions from the interceptor middleware for exceptions app [#1379](https://github.com/getsentry/sentry-ruby/pull/1379)
|
24
|
+
- Fixes [#1371](https://github.com/getsentry/sentry-ruby/issues/1371)
|
25
|
+
- Re-position CaptureExceptions middleware to reduce tracing noise [#1405](https://github.com/getsentry/sentry-ruby/pull/1405)
|
26
|
+
|
27
|
+
## 4.3.4
|
28
|
+
|
29
|
+
- Don't assign Rails.logger if it's not present [#1387](https://github.com/getsentry/sentry-ruby/pull/1387)
|
30
|
+
- Fixes [#1386](https://github.com/getsentry/sentry-ruby/issues/1386)
|
31
|
+
|
32
|
+
## 4.3.3
|
33
|
+
|
34
|
+
- Correctly set the SDK's logger in sentry-rails [#1363](https://github.com/getsentry/sentry-ruby/pull/1363)
|
35
|
+
- Fixes [#1361](https://github.com/getsentry/sentry-ruby/issues/1361)
|
36
|
+
|
37
|
+
## 4.3.3-beta.0
|
38
|
+
|
39
|
+
- Minimize sentry-rails' dependency requirement [#1352](https://github.com/getsentry/sentry-ruby/pull/1352)
|
40
|
+
|
41
|
+
## 4.3.2
|
42
|
+
|
43
|
+
- Avoid recording SendEventJob's transaction [#1351](https://github.com/getsentry/sentry-ruby/pull/1351)
|
44
|
+
- Fixes [#1348](https://github.com/getsentry/sentry-ruby/issues/1348)
|
45
|
+
|
3
46
|
## 4.3.1
|
4
47
|
|
5
48
|
- Only apply background worker patch if ActiveRecord is loaded [#1350](https://github.com/getsentry/sentry-ruby/pull/1350)
|
@@ -22,6 +22,11 @@ if defined?(ActiveJob)
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def perform(event, hint = {})
|
25
|
+
# users don't need the tracing result of this job
|
26
|
+
if transaction = Sentry.get_current_scope.span
|
27
|
+
transaction.instance_variable_set(:@sampled, false)
|
28
|
+
end
|
29
|
+
|
25
30
|
Sentry.send_event(event, hint)
|
26
31
|
end
|
27
32
|
end
|
data/lib/sentry/rails.rb
CHANGED
@@ -12,6 +12,7 @@ module Sentry
|
|
12
12
|
private
|
13
13
|
|
14
14
|
def collect_exception(env)
|
15
|
+
return nil if env["sentry.already_captured"]
|
15
16
|
super || env["action_dispatch.exception"] || env["sentry.rescued_exception"]
|
16
17
|
end
|
17
18
|
|
@@ -30,15 +31,15 @@ module Sentry
|
|
30
31
|
end
|
31
32
|
|
32
33
|
def start_transaction(env, scope)
|
33
|
-
|
34
|
+
sentry_trace = env["HTTP_SENTRY_TRACE"]
|
35
|
+
options = { name: scope.transaction_name, op: transaction_op }
|
34
36
|
|
35
|
-
|
36
|
-
|
37
|
-
if @assets_regex && transaction.name.match?(@assets_regex)
|
38
|
-
transaction.instance_variable_set(:@sampled, false)
|
37
|
+
if @assets_regex && scope.transaction_name.match?(@assets_regex)
|
38
|
+
options.merge!(sampled: false)
|
39
39
|
end
|
40
40
|
|
41
|
-
transaction
|
41
|
+
transaction = Sentry::Transaction.from_sentry_trace(sentry_trace, **options) if sentry_trace
|
42
|
+
Sentry.start_transaction(transaction: transaction, **options)
|
42
43
|
end
|
43
44
|
end
|
44
45
|
end
|
@@ -1,3 +1,7 @@
|
|
1
|
+
require "sentry/rails/tracing/action_controller_subscriber"
|
2
|
+
require "sentry/rails/tracing/action_view_subscriber"
|
3
|
+
require "sentry/rails/tracing/active_record_subscriber"
|
4
|
+
|
1
5
|
module Sentry
|
2
6
|
class Configuration
|
3
7
|
attr_reader :rails
|
@@ -5,6 +9,17 @@ module Sentry
|
|
5
9
|
add_post_initialization_callback do
|
6
10
|
@rails = Sentry::Rails::Configuration.new
|
7
11
|
@excluded_exceptions = @excluded_exceptions.concat(Sentry::Rails::IGNORE_DEFAULT)
|
12
|
+
|
13
|
+
if ::Rails.logger
|
14
|
+
@logger = ::Rails.logger
|
15
|
+
else
|
16
|
+
@logger.warn(Sentry::LOGGER_PROGNAME) do
|
17
|
+
<<~MSG
|
18
|
+
sentry-rails can't detect Rails.logger. it may be caused by misplacement of the SDK initialization code
|
19
|
+
please make sure you place the Sentry.init block under the `config/initializers` folder, e.g. `config/initializers/sentry.rb`
|
20
|
+
MSG
|
21
|
+
end
|
22
|
+
end
|
8
23
|
end
|
9
24
|
end
|
10
25
|
|
@@ -36,10 +51,16 @@ module Sentry
|
|
36
51
|
# In those cases, we should skip ActiveJob's reporting to avoid duplicated reports.
|
37
52
|
attr_accessor :skippable_job_adapters
|
38
53
|
|
54
|
+
attr_accessor :tracing_subscribers
|
55
|
+
|
39
56
|
def initialize
|
40
57
|
@report_rescued_exceptions = true
|
41
|
-
# TODO: Remove this in 4.2.0
|
42
58
|
@skippable_job_adapters = []
|
59
|
+
@tracing_subscribers = Set.new([
|
60
|
+
Sentry::Rails::Tracing::ActionControllerSubscriber,
|
61
|
+
Sentry::Rails::Tracing::ActionViewSubscriber,
|
62
|
+
Sentry::Rails::Tracing::ActiveRecordSubscriber
|
63
|
+
])
|
43
64
|
end
|
44
65
|
end
|
45
66
|
end
|
data/lib/sentry/rails/railtie.rb
CHANGED
@@ -1,18 +1,13 @@
|
|
1
|
-
require "rails"
|
2
1
|
require "sentry/rails/capture_exceptions"
|
3
2
|
require "sentry/rails/rescued_exception_interceptor"
|
4
3
|
require "sentry/rails/backtrace_cleaner"
|
5
|
-
require "sentry/rails/controller_methods"
|
6
|
-
require "sentry/rails/controller_transaction"
|
7
|
-
require "sentry/rails/overrides/streaming_reporter"
|
8
|
-
require "sentry/rails/overrides/file_handler"
|
9
4
|
|
10
5
|
module Sentry
|
11
6
|
class Railtie < ::Rails::Railtie
|
12
7
|
# middlewares can't be injected after initialize
|
13
8
|
initializer "sentry.use_rack_middleware" do |app|
|
14
|
-
#
|
15
|
-
app.config.middleware.
|
9
|
+
# placed after all the file-sending middlewares so we can avoid unnecessary transactions
|
10
|
+
app.config.middleware.insert_after ActionDispatch::Executor, Sentry::Rails::CaptureExceptions
|
16
11
|
# need to be placed at last to smuggle app exceptions via env
|
17
12
|
app.config.middleware.use(Sentry::Rails::RescuedExceptionInterceptor)
|
18
13
|
end
|
@@ -21,13 +16,11 @@ module Sentry
|
|
21
16
|
next unless Sentry.initialized?
|
22
17
|
|
23
18
|
configure_project_root
|
24
|
-
configure_sentry_logger
|
25
19
|
configure_trusted_proxies
|
26
|
-
extend_controller_methods
|
20
|
+
extend_controller_methods if defined?(ActionController)
|
27
21
|
extend_active_job if defined?(ActiveJob)
|
28
22
|
patch_background_worker if defined?(ActiveRecord)
|
29
|
-
override_streaming_reporter
|
30
|
-
override_file_handler if app.config.public_file_server.enabled
|
23
|
+
override_streaming_reporter if defined?(ActionView)
|
31
24
|
setup_backtrace_cleanup_callback
|
32
25
|
inject_breadcrumbs_logger
|
33
26
|
activate_tracing
|
@@ -37,10 +30,6 @@ module Sentry
|
|
37
30
|
Sentry.configuration.project_root = ::Rails.root.to_s
|
38
31
|
end
|
39
32
|
|
40
|
-
def configure_sentry_logger
|
41
|
-
Sentry.configuration.logger = ::Rails.logger
|
42
|
-
end
|
43
|
-
|
44
33
|
def configure_trusted_proxies
|
45
34
|
Sentry.configuration.trusted_proxies += Array(::Rails.application.config.action_dispatch.trusted_proxies)
|
46
35
|
end
|
@@ -51,6 +40,10 @@ module Sentry
|
|
51
40
|
end
|
52
41
|
|
53
42
|
def extend_controller_methods
|
43
|
+
require "sentry/rails/controller_methods"
|
44
|
+
require "sentry/rails/controller_transaction"
|
45
|
+
require "sentry/rails/overrides/streaming_reporter"
|
46
|
+
|
54
47
|
ActiveSupport.on_load :action_controller do
|
55
48
|
include Sentry::Rails::ControllerMethods
|
56
49
|
include Sentry::Rails::ControllerTransaction
|
@@ -78,19 +71,17 @@ module Sentry
|
|
78
71
|
end
|
79
72
|
|
80
73
|
def override_streaming_reporter
|
74
|
+
require "sentry/rails/overrides/streaming_reporter"
|
75
|
+
|
81
76
|
ActiveSupport.on_load :action_view do
|
82
77
|
ActionView::StreamingTemplateRenderer::Body.send(:prepend, Sentry::Rails::Overrides::StreamingReporter)
|
83
78
|
end
|
84
79
|
end
|
85
80
|
|
86
|
-
def override_file_handler
|
87
|
-
ActiveSupport.on_load :action_controller do
|
88
|
-
ActionDispatch::FileHandler.send(:prepend, Sentry::Rails::Overrides::FileHandler)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
81
|
def activate_tracing
|
93
82
|
if Sentry.configuration.tracing_enabled?
|
83
|
+
subscribers = Sentry.configuration.rails.tracing_subscribers
|
84
|
+
Sentry::Rails::Tracing.register_subscribers(subscribers)
|
94
85
|
Sentry::Rails::Tracing.subscribe_tracing_events
|
95
86
|
Sentry::Rails::Tracing.patch_active_support_notifications
|
96
87
|
end
|
@@ -20,12 +20,21 @@ module Sentry
|
|
20
20
|
copied_env = scope.rack_env.dup
|
21
21
|
copied_env["sentry.original_transaction"] = scope.transaction_name
|
22
22
|
scope.set_rack_env(copied_env)
|
23
|
+
|
24
|
+
if report_rescued_exceptions?
|
25
|
+
Sentry::Rails.capture_exception(e)
|
26
|
+
env["sentry.already_captured"] = true
|
27
|
+
end
|
23
28
|
end
|
24
29
|
|
25
|
-
env["sentry.rescued_exception"] = e if
|
30
|
+
env["sentry.rescued_exception"] = e if report_rescued_exceptions?
|
26
31
|
raise e
|
27
32
|
end
|
28
33
|
end
|
34
|
+
|
35
|
+
def report_rescued_exceptions?
|
36
|
+
Sentry.configuration.rails.report_rescued_exceptions
|
37
|
+
end
|
29
38
|
end
|
30
39
|
end
|
31
40
|
end
|
data/lib/sentry/rails/tracing.rb
CHANGED
@@ -1,18 +1,19 @@
|
|
1
|
-
require "sentry/rails/tracing/abstract_subscriber"
|
2
|
-
require "sentry/rails/tracing/active_record_subscriber"
|
3
|
-
require "sentry/rails/tracing/action_controller_subscriber"
|
4
|
-
require "sentry/rails/tracing/action_view_subscriber"
|
5
|
-
|
6
1
|
module Sentry
|
7
2
|
module Rails
|
8
3
|
module Tracing
|
9
|
-
|
4
|
+
def self.register_subscribers(subscribers)
|
5
|
+
@subscribers = subscribers
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.subscribers
|
9
|
+
@subscribers
|
10
|
+
end
|
10
11
|
|
11
12
|
def self.subscribe_tracing_events
|
12
13
|
# need to avoid duplicated subscription
|
13
14
|
return if @subscribed
|
14
15
|
|
15
|
-
|
16
|
+
subscribers.each(&:subscribe!)
|
16
17
|
|
17
18
|
@subscribed = true
|
18
19
|
end
|
@@ -20,7 +21,7 @@ module Sentry
|
|
20
21
|
def self.unsubscribe_tracing_events
|
21
22
|
return unless @subscribed
|
22
23
|
|
23
|
-
|
24
|
+
subscribers.each(&:unsubscribe!)
|
24
25
|
|
25
26
|
@subscribed = false
|
26
27
|
end
|
data/lib/sentry/rails/version.rb
CHANGED
data/sentry-rails.gemspec
CHANGED
@@ -22,6 +22,6 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
23
|
spec.require_paths = ["lib"]
|
24
24
|
|
25
|
-
spec.add_dependency "
|
26
|
-
spec.add_dependency "sentry-ruby-core", "~> 4.
|
25
|
+
spec.add_dependency "railties", ">= 5.0"
|
26
|
+
spec.add_dependency "sentry-ruby-core", "~> 4.4.0.pre.beta"
|
27
27
|
end
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sentry-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.4.0.pre.beta.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sentry Team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: railties
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 4.
|
33
|
+
version: 4.4.0.pre.beta
|
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: 4.
|
40
|
+
version: 4.4.0.pre.beta
|
41
41
|
description: A gem that provides Rails integration for the Sentry error logger
|
42
42
|
email: accounts@sentry.io
|
43
43
|
executables: []
|
@@ -70,7 +70,6 @@ files:
|
|
70
70
|
- lib/sentry/rails/controller_methods.rb
|
71
71
|
- lib/sentry/rails/controller_transaction.rb
|
72
72
|
- lib/sentry/rails/engine.rb
|
73
|
-
- lib/sentry/rails/overrides/file_handler.rb
|
74
73
|
- lib/sentry/rails/overrides/streaming_reporter.rb
|
75
74
|
- lib/sentry/rails/railtie.rb
|
76
75
|
- lib/sentry/rails/rescued_exception_interceptor.rb
|
@@ -99,11 +98,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
99
98
|
version: '2.4'
|
100
99
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
100
|
requirements:
|
102
|
-
- - "
|
101
|
+
- - ">"
|
103
102
|
- !ruby/object:Gem::Version
|
104
|
-
version:
|
103
|
+
version: 1.3.1
|
105
104
|
requirements: []
|
106
|
-
rubygems_version: 3.0.3
|
105
|
+
rubygems_version: 3.0.3.1
|
107
106
|
signing_key:
|
108
107
|
specification_version: 4
|
109
108
|
summary: A gem that provides Rails integration for the Sentry error logger
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module Sentry
|
2
|
-
module Rails
|
3
|
-
module Overrides
|
4
|
-
module FileHandler
|
5
|
-
def serve(*args)
|
6
|
-
if Sentry.initialized? && current_transaction = Sentry.get_current_scope.span
|
7
|
-
# we don't want to expose a setter for @sampled just for this case
|
8
|
-
current_transaction.instance_variable_set(:@sampled, false)
|
9
|
-
end
|
10
|
-
|
11
|
-
super
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|