sentry-rails 4.8.2 → 4.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +8 -2
- data/lib/sentry/rails/action_cable.rb +96 -0
- data/lib/sentry/rails/active_job.rb +3 -1
- data/lib/sentry/rails/railtie.rb +13 -0
- data/lib/sentry/rails/version.rb +1 -1
- data/sentry-rails.gemspec +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6da9817b3be6ac851ff62a6da80d638fc75d4c170825e9a925a7e5be5f973cb1
|
4
|
+
data.tar.gz: 7f5f80ab0dbf75bbe9773aef1ac180ab014b0f3b19b33983dd3ab38c20ec0f8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e1650da3dc176bb53ff5e47d919996bc8445e80973cb8baef071fcfdf30f237bc73ade309e45d94396926d9f0138c3b2ed4563f8c9cc2238ea00c7204bac032
|
7
|
+
data.tar.gz: b59164c5df42130717d2217358cf7f072c0fa9fbda35c5361a87ed96a83abf41b32c94ffd3430031c3fe22354e24ee637ebff390651e360bdb328375a3e354da
|
data/Gemfile
CHANGED
@@ -6,17 +6,23 @@ gem "sentry-ruby", path: "../sentry-ruby"
|
|
6
6
|
|
7
7
|
rails_version = ENV["RAILS_VERSION"]
|
8
8
|
rails_version = "6.1.0" if rails_version.nil?
|
9
|
+
rails_version = Gem::Version.new(rails_version)
|
9
10
|
|
10
11
|
gem 'activerecord-jdbcmysql-adapter', platform: :jruby
|
11
12
|
gem "jdbc-sqlite3", platform: :jruby
|
12
13
|
|
13
|
-
if rails_version
|
14
|
+
if rails_version < Gem::Version.new("6.0.0")
|
14
15
|
gem "sqlite3", "~> 1.3.0", platform: :ruby
|
15
16
|
else
|
16
17
|
gem "sqlite3", platform: :ruby
|
17
18
|
end
|
18
19
|
|
19
|
-
|
20
|
+
if rails_version >= Gem::Version.new("7.0.0")
|
21
|
+
gem "rails", github: "rails/rails", branch: "7-0-stable"
|
22
|
+
else
|
23
|
+
gem "rails", "~> #{rails_version}"
|
24
|
+
end
|
25
|
+
|
20
26
|
gem "sprockets-rails"
|
21
27
|
|
22
28
|
gem "sidekiq"
|
@@ -0,0 +1,96 @@
|
|
1
|
+
module Sentry
|
2
|
+
module Rails
|
3
|
+
module ActionCableExtensions
|
4
|
+
class ErrorHandler
|
5
|
+
class << self
|
6
|
+
def capture(connection, transaction_name:, extra_context: nil, &block)
|
7
|
+
return block.call unless Sentry.initialized?
|
8
|
+
# ActionCable's ConnectionStub (for testing) doesn't implement the exact same interfaces as Connection::Base.
|
9
|
+
# One thing that's missing is `env`. So calling `connection.env` direclty will fail in test environments when `stub_connection` is used.
|
10
|
+
# See https://github.com/getsentry/sentry-ruby/pull/1684 for more information.
|
11
|
+
env = connection.respond_to?(:env) ? connection.env : {}
|
12
|
+
|
13
|
+
Sentry.with_scope do |scope|
|
14
|
+
scope.set_rack_env(env)
|
15
|
+
scope.set_context("action_cable", extra_context) if extra_context
|
16
|
+
scope.set_transaction_name(transaction_name)
|
17
|
+
transaction = start_transaction(env, scope.transaction_name)
|
18
|
+
scope.set_span(transaction) if transaction
|
19
|
+
|
20
|
+
begin
|
21
|
+
block.call
|
22
|
+
finish_transaction(transaction, 200)
|
23
|
+
rescue Exception => e # rubocop:disable Lint/RescueException
|
24
|
+
Sentry::Rails.capture_exception(e)
|
25
|
+
finish_transaction(transaction, 500)
|
26
|
+
|
27
|
+
raise
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def start_transaction(env, transaction_name)
|
33
|
+
sentry_trace = env["HTTP_SENTRY_TRACE"]
|
34
|
+
options = { name: transaction_name, op: "rails.action_cable".freeze }
|
35
|
+
transaction = Sentry::Transaction.from_sentry_trace(sentry_trace, **options) if sentry_trace
|
36
|
+
Sentry.start_transaction(transaction: transaction, **options)
|
37
|
+
end
|
38
|
+
|
39
|
+
def finish_transaction(transaction, status_code)
|
40
|
+
return unless transaction
|
41
|
+
|
42
|
+
transaction.set_http_status(status_code)
|
43
|
+
transaction.finish
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
module Connection
|
49
|
+
private
|
50
|
+
|
51
|
+
def handle_open
|
52
|
+
ErrorHandler.capture(self, transaction_name: "#{self.class.name}#connect") do
|
53
|
+
super
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def handle_close
|
58
|
+
ErrorHandler.capture(self, transaction_name: "#{self.class.name}#disconnect") do
|
59
|
+
super
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
module Channel
|
65
|
+
module Subscriptions
|
66
|
+
def self.included(base)
|
67
|
+
base.class_eval do
|
68
|
+
set_callback :subscribe, :around, ->(_, block) { sentry_capture(:subscribed, &block) }, prepend: true
|
69
|
+
set_callback :unsubscribe, :around, ->(_, block) { sentry_capture(:unsubscribed, &block) }, prepend: true
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
def sentry_capture(hook, &block)
|
76
|
+
extra_context = { params: params }
|
77
|
+
|
78
|
+
ErrorHandler.capture(connection, transaction_name: "#{self.class.name}##{hook}", extra_context: extra_context, &block)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
module Actions
|
83
|
+
private
|
84
|
+
|
85
|
+
def dispatch_action(action, data)
|
86
|
+
extra_context = { params: params, data: data }
|
87
|
+
|
88
|
+
ErrorHandler.capture(connection, transaction_name: "#{self.class.name}##{action}", extra_context: extra_context) do
|
89
|
+
super
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -24,9 +24,11 @@ module Sentry
|
|
24
24
|
|
25
25
|
scope.set_span(transaction) if transaction
|
26
26
|
|
27
|
-
block.call
|
27
|
+
return_value = block.call
|
28
28
|
|
29
29
|
finish_sentry_transaction(transaction, 200)
|
30
|
+
|
31
|
+
return_value
|
30
32
|
rescue Exception => e # rubocop:disable Lint/RescueException
|
31
33
|
finish_sentry_transaction(transaction, 500)
|
32
34
|
|
data/lib/sentry/rails/railtie.rb
CHANGED
@@ -22,6 +22,19 @@ module Sentry
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
initializer "sentry.extend_action_cable", before: :eager_load! do |app|
|
26
|
+
ActiveSupport.on_load(:action_cable_connection) do
|
27
|
+
require "sentry/rails/action_cable"
|
28
|
+
prepend Sentry::Rails::ActionCableExtensions::Connection
|
29
|
+
end
|
30
|
+
|
31
|
+
ActiveSupport.on_load(:action_cable_channel) do
|
32
|
+
require "sentry/rails/action_cable"
|
33
|
+
include Sentry::Rails::ActionCableExtensions::Channel::Subscriptions
|
34
|
+
prepend Sentry::Rails::ActionCableExtensions::Channel::Actions
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
25
38
|
config.after_initialize do |app|
|
26
39
|
next unless Sentry.initialized?
|
27
40
|
|
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: 4.
|
4
|
+
version: 4.9.2
|
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-01-
|
11
|
+
date: 2022-01-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: 4.
|
33
|
+
version: 4.9.2
|
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.9.2
|
41
41
|
description: A gem that provides Rails integration for the Sentry error logger
|
42
42
|
email: accounts@sentry.io
|
43
43
|
executables: []
|
@@ -60,6 +60,7 @@ files:
|
|
60
60
|
- bin/setup
|
61
61
|
- lib/sentry-rails.rb
|
62
62
|
- lib/sentry/rails.rb
|
63
|
+
- lib/sentry/rails/action_cable.rb
|
63
64
|
- lib/sentry/rails/active_job.rb
|
64
65
|
- lib/sentry/rails/background_worker.rb
|
65
66
|
- lib/sentry/rails/backtrace_cleaner.rb
|