sentry-rails 4.2.2 → 4.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +29 -0
- data/Gemfile +3 -1
- data/app/jobs/sentry/send_event_job.rb +5 -0
- data/lib/sentry/rails.rb +1 -0
- data/lib/sentry/rails/active_job.rb +18 -3
- data/lib/sentry/rails/background_worker.rb +12 -0
- data/lib/sentry/rails/capture_exceptions.rb +9 -4
- data/lib/sentry/rails/configuration.rb +1 -0
- data/lib/sentry/rails/railtie.rb +16 -13
- data/lib/sentry/rails/version.rb +1 -1
- data/sentry-rails.gemspec +2 -2
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1790a49cf858500aa57dd9290d37e794bb969b7b961e11047e8df61a090ec95
|
4
|
+
data.tar.gz: a9626020e87f157e1eed1c2f49296f796406958e789c379915fbecf5da49ff9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d2d760f4fa7ac34e39294169f8be9c19d9ff7e19fb1c7a89d3205ff843b626bf90f89ee516b248539d180ac347c907ca23c55953033eb1d8588fd15e57f833c
|
7
|
+
data.tar.gz: 3fd609010fba1eef3a56ce52a5f09e7d58ad5f43f1c3b039d4deed3bdb89f276da434a2e76d2b6f06d79ae85c4ebb7daa24179503b607d3b6be23808005565ce
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,34 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 4.3.3
|
4
|
+
|
5
|
+
- Correctly set the SDK's logger in sentry-rails [#1363](https://github.com/getsentry/sentry-ruby/pull/1363)
|
6
|
+
- Fixes [#1361](https://github.com/getsentry/sentry-ruby/issues/1361)
|
7
|
+
|
8
|
+
## 4.3.3-beta.0
|
9
|
+
|
10
|
+
- Minimize sentry-rails' dependency requirement [#1352](https://github.com/getsentry/sentry-ruby/pull/1352)
|
11
|
+
|
12
|
+
## 4.3.2
|
13
|
+
|
14
|
+
- Avoid recording SendEventJob's transaction [#1351](https://github.com/getsentry/sentry-ruby/pull/1351)
|
15
|
+
- Fixes [#1348](https://github.com/getsentry/sentry-ruby/issues/1348)
|
16
|
+
|
17
|
+
## 4.3.1
|
18
|
+
|
19
|
+
- Only apply background worker patch if ActiveRecord is loaded [#1350](https://github.com/getsentry/sentry-ruby/pull/1350)
|
20
|
+
- Fixes [#1342](https://github.com/getsentry/sentry-ruby/issues/1342) and [#1346](https://github.com/getsentry/sentry-ruby/issues/1346)
|
21
|
+
|
22
|
+
## 4.3.0
|
23
|
+
|
24
|
+
### Features
|
25
|
+
|
26
|
+
- Support performance monitoring on ActiveJob execution [#1304](https://github.com/getsentry/sentry-ruby/pull/1304)
|
27
|
+
|
28
|
+
### Bug Fixes
|
29
|
+
|
30
|
+
- Prevent background workers from holding ActiveRecord connections [#1320](https://github.com/getsentry/sentry-ruby/pull/1320)
|
31
|
+
|
3
32
|
## 4.2.2
|
4
33
|
|
5
34
|
- Always define Sentry::SendEventJob to avoid eager load issues [#1286](https://github.com/getsentry/sentry-ruby/pull/1286)
|
data/Gemfile
CHANGED
@@ -17,11 +17,13 @@ end
|
|
17
17
|
|
18
18
|
gem "rails", "~> #{rails_version}"
|
19
19
|
gem "sprockets-rails"
|
20
|
+
|
21
|
+
gem "rspec", "~> 3.0"
|
22
|
+
gem "rspec-retry"
|
20
23
|
gem "rspec-rails", "~> 4.0"
|
21
24
|
gem "codecov", "0.2.12"
|
22
25
|
|
23
26
|
gem "rake", "~> 12.0"
|
24
|
-
gem "rspec", "~> 3.0"
|
25
27
|
|
26
28
|
# TODO: Remove this if https://github.com/jruby/jruby/issues/6547 is addressed
|
27
29
|
gem "i18n", "<= 1.8.7"
|
@@ -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
@@ -8,8 +8,8 @@ module Sentry
|
|
8
8
|
if already_supported_by_specific_integration?(job)
|
9
9
|
block.call
|
10
10
|
else
|
11
|
-
Sentry.with_scope do
|
12
|
-
capture_and_reraise_with_sentry(job, block)
|
11
|
+
Sentry.with_scope do |scope|
|
12
|
+
capture_and_reraise_with_sentry(job, scope, block)
|
13
13
|
end
|
14
14
|
end
|
15
15
|
else
|
@@ -19,10 +19,18 @@ module Sentry
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
def capture_and_reraise_with_sentry(job, block)
|
22
|
+
def capture_and_reraise_with_sentry(job, scope, block)
|
23
|
+
scope.set_transaction_name(job.class.name)
|
24
|
+
transaction = Sentry.start_transaction(name: scope.transaction_name, op: "active_job")
|
25
|
+
|
26
|
+
scope.set_span(transaction) if transaction
|
27
|
+
|
23
28
|
block.call
|
29
|
+
|
30
|
+
finish_transaction(transaction, 200)
|
24
31
|
rescue Exception => e # rubocop:disable Lint/RescueException
|
25
32
|
rescue_handler_result = rescue_with_handler(e)
|
33
|
+
finish_transaction(transaction, 500)
|
26
34
|
return rescue_handler_result if rescue_handler_result
|
27
35
|
|
28
36
|
Sentry::Rails.capture_exception(
|
@@ -36,6 +44,13 @@ module Sentry
|
|
36
44
|
raise e
|
37
45
|
end
|
38
46
|
|
47
|
+
def finish_transaction(transaction, status)
|
48
|
+
return unless transaction
|
49
|
+
|
50
|
+
transaction.set_http_status(status)
|
51
|
+
transaction.finish
|
52
|
+
end
|
53
|
+
|
39
54
|
def already_supported_by_specific_integration?(job)
|
40
55
|
Sentry.configuration.rails.skippable_job_adapters.include?(job.class.queue_adapter.class.to_s)
|
41
56
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Sentry
|
2
|
+
class BackgroundWorker
|
3
|
+
def perform(&block)
|
4
|
+
@executor.post do
|
5
|
+
# make sure the background worker returns AR connection if it accidentally acquire one during serialization
|
6
|
+
ActiveRecord::Base.connection_pool.with_connection do
|
7
|
+
block.call
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -29,11 +29,16 @@ module Sentry
|
|
29
29
|
Sentry::Rails.capture_exception(exception)
|
30
30
|
end
|
31
31
|
|
32
|
-
def
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
def start_transaction(env, scope)
|
33
|
+
transaction = super
|
34
|
+
|
35
|
+
return unless transaction
|
36
|
+
|
37
|
+
if @assets_regex && transaction.name.match?(@assets_regex)
|
38
|
+
transaction.instance_variable_set(:@sampled, false)
|
36
39
|
end
|
40
|
+
|
41
|
+
transaction
|
37
42
|
end
|
38
43
|
end
|
39
44
|
end
|
data/lib/sentry/rails/railtie.rb
CHANGED
@@ -1,11 +1,6 @@
|
|
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
|
@@ -21,12 +16,12 @@ 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
|
-
|
29
|
-
|
22
|
+
patch_background_worker if defined?(ActiveRecord)
|
23
|
+
override_streaming_reporter if defined?(ActionView)
|
24
|
+
override_file_handler if defined?(ActionDispatch) && app.config.public_file_server.enabled
|
30
25
|
setup_backtrace_cleanup_callback
|
31
26
|
inject_breadcrumbs_logger
|
32
27
|
activate_tracing
|
@@ -36,10 +31,6 @@ module Sentry
|
|
36
31
|
Sentry.configuration.project_root = ::Rails.root.to_s
|
37
32
|
end
|
38
33
|
|
39
|
-
def configure_sentry_logger
|
40
|
-
Sentry.configuration.logger = ::Rails.logger
|
41
|
-
end
|
42
|
-
|
43
34
|
def configure_trusted_proxies
|
44
35
|
Sentry.configuration.trusted_proxies += Array(::Rails.application.config.action_dispatch.trusted_proxies)
|
45
36
|
end
|
@@ -50,6 +41,10 @@ module Sentry
|
|
50
41
|
end
|
51
42
|
|
52
43
|
def extend_controller_methods
|
44
|
+
require "sentry/rails/controller_methods"
|
45
|
+
require "sentry/rails/controller_transaction"
|
46
|
+
require "sentry/rails/overrides/streaming_reporter"
|
47
|
+
|
53
48
|
ActiveSupport.on_load :action_controller do
|
54
49
|
include Sentry::Rails::ControllerMethods
|
55
50
|
include Sentry::Rails::ControllerTransaction
|
@@ -57,6 +52,10 @@ module Sentry
|
|
57
52
|
end
|
58
53
|
end
|
59
54
|
|
55
|
+
def patch_background_worker
|
56
|
+
require "sentry/rails/background_worker"
|
57
|
+
end
|
58
|
+
|
60
59
|
def inject_breadcrumbs_logger
|
61
60
|
if Sentry.configuration.breadcrumbs_logger.include?(:active_support_logger)
|
62
61
|
require 'sentry/rails/breadcrumb/active_support_logger'
|
@@ -73,12 +72,16 @@ module Sentry
|
|
73
72
|
end
|
74
73
|
|
75
74
|
def override_streaming_reporter
|
75
|
+
require "sentry/rails/overrides/streaming_reporter"
|
76
|
+
|
76
77
|
ActiveSupport.on_load :action_view do
|
77
78
|
ActionView::StreamingTemplateRenderer::Body.send(:prepend, Sentry::Rails::Overrides::StreamingReporter)
|
78
79
|
end
|
79
80
|
end
|
80
81
|
|
81
82
|
def override_file_handler
|
83
|
+
require "sentry/rails/overrides/file_handler"
|
84
|
+
|
82
85
|
ActiveSupport.on_load :action_controller do
|
83
86
|
ActionDispatch::FileHandler.send(:prepend, Sentry::Rails::Overrides::FileHandler)
|
84
87
|
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.3.0"
|
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.3.3
|
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-03-26 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.3.0
|
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.3.0
|
41
41
|
description: A gem that provides Rails integration for the Sentry error logger
|
42
42
|
email: accounts@sentry.io
|
43
43
|
executables: []
|
@@ -62,6 +62,7 @@ files:
|
|
62
62
|
- lib/sentry-rails.rb
|
63
63
|
- lib/sentry/rails.rb
|
64
64
|
- lib/sentry/rails/active_job.rb
|
65
|
+
- lib/sentry/rails/background_worker.rb
|
65
66
|
- lib/sentry/rails/backtrace_cleaner.rb
|
66
67
|
- lib/sentry/rails/breadcrumb/active_support_logger.rb
|
67
68
|
- lib/sentry/rails/capture_exceptions.rb
|