sentry-rails 4.8.3 → 4.9.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d3fac86beaf3aa169dfed1a73e0836e066bd8ec0a4c0c79dd91391d8dac20e29
4
- data.tar.gz: 264f9fa5c867f13c8d1a69263e5956f1aa5e6123af5937db597cb4e43b6396dd
3
+ metadata.gz: 8c7102e219c8ea6e6921580e0f652dc5298fd4b436639824b92c3ed11f1f7ebb
4
+ data.tar.gz: 81b4f1c263508ee2deedb06a14704a695e2807254d34773c3fd41a1827497e8e
5
5
  SHA512:
6
- metadata.gz: 0a0890d576cdbe46e5a80834820014fc4bd5c201075f7ffad9156ec9d523783e799daa789ac5bfb9702980957fbcf6abd4277269dbb12ebe6a501bdf11273818
7
- data.tar.gz: 56be8d335560de6e7e696ce0c62b0a5e86f672d4366a4c4da97fa79c8e7731c9b5778b79a8150e52799beedc7b688a1c3a436ea590ee3baa914f0355dd3828e7
6
+ metadata.gz: 33c87f90cd6533322a1d178ca0a6c9b79ea1d823f498f7bdf6ff2a262b1a62d4bec14a6ca3225dee51b516d4767831ada9eca0942c3eba001c109d53712fc963
7
+ data.tar.gz: 59a10e73ea3fdb8b82c6b7943ad90275ce3a6d940493f982be9212a356a873401ee6eba358e07870101be59144205ce6c22c81ca4b27c1075cded1fab1aa9668
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.to_f < 6
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
- gem "rails", "~> #{rails_version}"
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,90 @@
1
+ module Sentry
2
+ module Rails
3
+ module ActionCableExtensions
4
+ class ErrorHandler
5
+ class << self
6
+ def capture(env, transaction_name:, extra_context: nil, &block)
7
+ Sentry.with_scope do |scope|
8
+ scope.set_rack_env(env)
9
+ scope.set_context("action_cable", extra_context) if extra_context
10
+ scope.set_transaction_name(transaction_name)
11
+ transaction = start_transaction(env, scope.transaction_name)
12
+ scope.set_span(transaction) if transaction
13
+
14
+ begin
15
+ block.call
16
+ finish_transaction(transaction, 200)
17
+ rescue Exception => e # rubocop:disable Lint/RescueException
18
+ Sentry::Rails.capture_exception(e)
19
+ finish_transaction(transaction, 500)
20
+
21
+ raise
22
+ end
23
+ end
24
+ end
25
+
26
+ def start_transaction(env, transaction_name)
27
+ sentry_trace = env["HTTP_SENTRY_TRACE"]
28
+ options = { name: transaction_name, op: "rails.action_cable".freeze }
29
+ transaction = Sentry::Transaction.from_sentry_trace(sentry_trace, **options) if sentry_trace
30
+ Sentry.start_transaction(transaction: transaction, **options)
31
+ end
32
+
33
+ def finish_transaction(transaction, status_code)
34
+ return unless transaction
35
+
36
+ transaction.set_http_status(status_code)
37
+ transaction.finish
38
+ end
39
+ end
40
+ end
41
+
42
+ module Connection
43
+ private
44
+
45
+ def handle_open
46
+ ErrorHandler.capture(env, transaction_name: "#{self.class.name}#connect") do
47
+ super
48
+ end
49
+ end
50
+
51
+ def handle_close
52
+ ErrorHandler.capture(env, transaction_name: "#{self.class.name}#disconnect") do
53
+ super
54
+ end
55
+ end
56
+ end
57
+
58
+ module Channel
59
+ module Subscriptions
60
+ def self.included(base)
61
+ base.class_eval do
62
+ set_callback :subscribe, :around, ->(_, block) { sentry_capture(:subscribed, &block) }, prepend: true
63
+ set_callback :unsubscribe, :around, ->(_, block) { sentry_capture(:unsubscribed, &block) }, prepend: true
64
+ end
65
+ end
66
+
67
+ private
68
+
69
+ def sentry_capture(hook, &block)
70
+ extra_context = { params: params }
71
+
72
+ ErrorHandler.capture(connection.env, transaction_name: "#{self.class.name}##{hook}", extra_context: extra_context, &block)
73
+ end
74
+ end
75
+
76
+ module Actions
77
+ private
78
+
79
+ def dispatch_action(action, data)
80
+ extra_context = { params: params, data: data }
81
+
82
+ ErrorHandler.capture(connection.env, transaction_name: "#{self.class.name}##{action}", extra_context: extra_context) do
83
+ super
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
90
+ end
@@ -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
 
@@ -1,5 +1,5 @@
1
1
  module Sentry
2
2
  module Rails
3
- VERSION = "4.8.3"
3
+ VERSION = "4.9.0"
4
4
  end
5
5
  end
data/sentry-rails.gemspec CHANGED
@@ -23,5 +23,5 @@ Gem::Specification.new do |spec|
23
23
  spec.require_paths = ["lib"]
24
24
 
25
25
  spec.add_dependency "railties", ">= 5.0"
26
- spec.add_dependency "sentry-ruby-core", "~> 4.8.3"
26
+ spec.add_dependency "sentry-ruby-core", "~> 4.9.0"
27
27
  end
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.8.3
4
+ version: 4.9.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: 2022-01-05 00:00:00.000000000 Z
11
+ date: 2022-01-07 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.8.3
33
+ version: 4.9.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.8.3
40
+ version: 4.9.0
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