sentry-rails 5.21.0 → 5.22.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 261db1bfb141ef1e485ba222e02c98dc0fd870270ba5e88cfe7a9b7f3b63ad1d
4
- data.tar.gz: 762710544720a0999630de260665fde9cc863a9cd3decc1265ed6110c743a098
3
+ metadata.gz: f2948b15c64519057adfdac9e871d8cc43b1bd460a24d20d663bc94328aced2a
4
+ data.tar.gz: 4e1313e0b4b5ee7be191a7dde122b704f10fe868130552f54fd5f988f408b7a4
5
5
  SHA512:
6
- metadata.gz: c4cea0d02e60caed2506051d1801969809e8d4282b918ff73d1ffda19edfe5d80b2c2948366d351dd9fed170129cc3ca6d1fbfe61e17d190b0aa284a4dc51761
7
- data.tar.gz: 01415df0d35fc7ee3b795b672a13382e758d2ae626a51fad138fd8f2d9756ef4e6a33549cba4e334bb694c7e7fb562cd3746f7aeeed45fda6b9be0b0a2cbedc3
6
+ metadata.gz: 3feff4005efedb10b5adeac293b082aa11cde83eb07703202be32a2ba90283c0577f9ae20198e58fb4d594293c870b0e43ec465734f4e455949e1db13454dc6d
7
+ data.tar.gz: 42321b1c07e3c82851850df9f277920da6ce816da933afbda3ce049db40394abcdef1309ffaa73d703a40e6063ea40e301206c85c63d4f6728b03d7c341b8e98
data/Gemfile CHANGED
@@ -12,40 +12,38 @@ platform :jruby do
12
12
  gem "jdbc-sqlite3"
13
13
  end
14
14
 
15
+ ruby_version = Gem::Version.new(RUBY_VERSION)
16
+
15
17
  rails_version = ENV["RAILS_VERSION"]
16
- rails_version = "7.1.0" if rails_version.nil?
18
+ rails_version = "8.0.0" if rails_version.nil?
17
19
  rails_version = Gem::Version.new(rails_version)
18
20
 
19
- if rails_version < Gem::Version.new("6.0.0")
20
- gem "sqlite3", "~> 1.3.0", platform: :ruby
21
- else
22
- if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.7.0")
23
- gem "sqlite3", "~> 1.7.3", platform: :ruby
24
- else
25
- gem "sqlite3", "~> 1.6.9", platform: :ruby
26
- end
27
- end
21
+ gem "rails", "~> #{rails_version}"
28
22
 
29
- if rails_version >= Gem::Version.new("8.0.0.alpha")
30
- gem "rails", github: "rails/rails"
23
+ if rails_version >= Gem::Version.new("8.0.0")
31
24
  gem "rspec-rails"
25
+ gem "sqlite3", platform: :ruby
32
26
  elsif rails_version >= Gem::Version.new("7.1.0")
33
- gem "rails", "~> #{rails_version}"
34
27
  gem "rspec-rails"
28
+ gem "sqlite3", "~> 1.7.3", platform: :ruby
29
+ elsif rails_version >= Gem::Version.new("6.1.0")
30
+ gem "rspec-rails", "~> 4.0"
31
+
32
+ if ruby_version >= Gem::Version.new("2.7.0")
33
+ gem "sqlite3", "~> 1.7.3", platform: :ruby
34
+ else
35
+ gem "sqlite3", "~> 1.6.9", platform: :ruby
36
+ end
35
37
  else
36
38
  gem "rspec-rails", "~> 4.0"
37
- gem "rails", "~> #{rails_version}"
38
39
  gem "psych", "~> 3.0.0"
39
- end
40
40
 
41
- gem "mini_magick"
42
-
43
- gem "sprockets-rails"
44
-
45
- gem "sidekiq"
46
-
47
-
48
- ruby_version = Gem::Version.new(RUBY_VERSION)
41
+ if rails_version >= Gem::Version.new("6.0.0")
42
+ gem "sqlite3", "~> 1.4.0", platform: :ruby
43
+ else
44
+ gem "sqlite3", "~> 1.3.0", platform: :ruby
45
+ end
46
+ end
49
47
 
50
48
  if ruby_version < Gem::Version.new("2.5.0")
51
49
  # https://github.com/flavorjones/loofah/pull/267
@@ -53,6 +51,10 @@ if ruby_version < Gem::Version.new("2.5.0")
53
51
  gem "loofah", "2.20.0"
54
52
  end
55
53
 
54
+ gem "mini_magick"
55
+
56
+ gem "sprockets-rails"
57
+
56
58
  gem "benchmark-ips"
57
59
  gem "benchmark_driver"
58
60
  gem "benchmark-ipsa"
@@ -11,13 +11,11 @@ module Sentry
11
11
 
12
12
  def initialize
13
13
  super
14
- # we don't want any default silencers because they're too aggressive
14
+ # We don't want any default silencers because they're too aggressive
15
15
  remove_silencers!
16
+ # We don't want any default filters because Rails 7.2 starts shortening the paths. See #2472
17
+ remove_filters!
16
18
 
17
- @root = "#{Sentry.configuration.project_root}/"
18
- add_filter do |line|
19
- line.start_with?(@root) ? line.from(@root.size) : line
20
- end
21
19
  add_filter do |line|
22
20
  if line =~ RENDER_TEMPLATE_PATTERN
23
21
  line.sub(RENDER_TEMPLATE_PATTERN, "")
@@ -4,6 +4,7 @@ require "sentry/rails/tracing/action_controller_subscriber"
4
4
  require "sentry/rails/tracing/action_view_subscriber"
5
5
  require "sentry/rails/tracing/active_record_subscriber"
6
6
  require "sentry/rails/tracing/active_storage_subscriber"
7
+ require "sentry/rails/tracing/active_support_subscriber"
7
8
 
8
9
  module Sentry
9
10
  class Configuration
@@ -164,6 +165,7 @@ module Sentry
164
165
  end
165
166
  @tracing_subscribers = Set.new([
166
167
  Sentry::Rails::Tracing::ActionViewSubscriber,
168
+ Sentry::Rails::Tracing::ActiveSupportSubscriber,
167
169
  Sentry::Rails::Tracing::ActiveRecordSubscriber,
168
170
  Sentry::Rails::Tracing::ActiveStorageSubscriber
169
171
  ])
@@ -23,8 +23,10 @@ module Sentry
23
23
  child_span.set_http_status(response.status)
24
24
  child_span.set_data(:format, request.format)
25
25
  child_span.set_data(:method, request.method)
26
- child_span.set_data(:path, request.path)
27
- child_span.set_data(:params, request.params)
26
+
27
+ pii = Sentry.configuration.send_default_pii
28
+ child_span.set_data(:path, pii ? request.fullpath : request.filtered_path)
29
+ child_span.set_data(:params, pii ? request.params : request.filtered_parameters)
28
30
  end
29
31
 
30
32
  result
@@ -27,7 +27,20 @@ module Sentry
27
27
  hint.merge!(context.delete(:hint))
28
28
  end
29
29
 
30
- Sentry::Rails.capture_exception(error, level: severity, contexts: { "rails.error" => context }, tags: tags, hint: hint)
30
+ options = { level: severity, contexts: { "rails.error" => context }, tags: tags, hint: hint }
31
+
32
+ case error
33
+ when String
34
+ Sentry::Rails.capture_message(error, **options)
35
+ when Exception
36
+ Sentry::Rails.capture_exception(error, **options)
37
+ else
38
+ log_debug("Expected an Exception or a String, got: #{error.inspect}")
39
+ end
40
+ end
41
+
42
+ def log_debug(message)
43
+ Sentry.configuration.logger.debug(message)
31
44
  end
32
45
  end
33
46
  end
@@ -19,7 +19,16 @@ module Sentry
19
19
  end
20
20
 
21
21
  def report_rescued_exceptions?
22
- Sentry.configuration.rails.report_rescued_exceptions
22
+ # In rare edge cases, `Sentry.configuration` might be `nil` here.
23
+ # Hence, we use a safe navigation and fallback to a reasonable default
24
+ # of `true` in case the configuration couldn't be loaded.
25
+ # See https://github.com/getsentry/sentry-ruby/issues/2386
26
+ report_rescued_exceptions = Sentry.configuration&.rails&.report_rescued_exceptions
27
+ return report_rescued_exceptions unless report_rescued_exceptions.nil?
28
+
29
+ # `true` is the default for `report_rescued_exceptions`, as specified in
30
+ # `sentry-rails/lib/sentry/rails/configuration.rb`.
31
+ true
23
32
  end
24
33
  end
25
34
  end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "sentry/rails/tracing/abstract_subscriber"
4
+
5
+ module Sentry
6
+ module Rails
7
+ module Tracing
8
+ class ActiveSupportSubscriber < AbstractSubscriber
9
+ READ_EVENT_NAMES = %w[
10
+ cache_read.active_support
11
+ ].freeze
12
+
13
+ WRITE_EVENT_NAMES = %w[
14
+ cache_write.active_support
15
+ cache_increment.active_support
16
+ cache_decrement.active_support
17
+ ].freeze
18
+
19
+ REMOVE_EVENT_NAMES = %w[
20
+ cache_delete.active_support
21
+ ].freeze
22
+
23
+ FLUSH_EVENT_NAMES = %w[
24
+ cache_prune.active_support
25
+ ].freeze
26
+
27
+ EVENT_NAMES = READ_EVENT_NAMES + WRITE_EVENT_NAMES + REMOVE_EVENT_NAMES + FLUSH_EVENT_NAMES
28
+
29
+ SPAN_ORIGIN = "auto.cache.rails"
30
+
31
+ def self.subscribe!
32
+ subscribe_to_event(EVENT_NAMES) do |event_name, duration, payload|
33
+ record_on_current_span(
34
+ op: operation_name(event_name),
35
+ origin: SPAN_ORIGIN,
36
+ start_timestamp: payload[START_TIMESTAMP_NAME],
37
+ description: payload[:store],
38
+ duration: duration
39
+ ) do |span|
40
+ span.set_data("cache.key", [*payload[:key]].select { |key| Utils::EncodingHelper.valid_utf_8?(key) })
41
+ span.set_data("cache.hit", payload[:hit] == true) # Handle nil case
42
+ end
43
+ end
44
+ end
45
+
46
+ def self.operation_name(event_name)
47
+ case
48
+ when READ_EVENT_NAMES.include?(event_name)
49
+ "cache.get"
50
+ when WRITE_EVENT_NAMES.include?(event_name)
51
+ "cache.put"
52
+ when REMOVE_EVENT_NAMES.include?(event_name)
53
+ "cache.remove"
54
+ when FLUSH_EVENT_NAMES.include?(event_name)
55
+ "cache.flush"
56
+ else
57
+ "other"
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sentry
4
4
  module Rails
5
- VERSION = "5.21.0"
5
+ VERSION = "5.22.1"
6
6
  end
7
7
  end
data/sentry-rails.gemspec CHANGED
@@ -31,5 +31,5 @@ Gem::Specification.new do |spec|
31
31
  spec.require_paths = ["lib"]
32
32
 
33
33
  spec.add_dependency "railties", ">= 5.0"
34
- spec.add_dependency "sentry-ruby", "~> 5.21.0"
34
+ spec.add_dependency "sentry-ruby", "~> 5.22.1"
35
35
  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: 5.21.0
4
+ version: 5.22.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sentry Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-10-07 00:00:00.000000000 Z
11
+ date: 2024-12-16 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: 5.21.0
33
+ version: 5.22.1
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: 5.21.0
40
+ version: 5.22.1
41
41
  description: A gem that provides Rails integration for the Sentry error logger
42
42
  email: accounts@sentry.io
43
43
  executables: []
@@ -82,17 +82,18 @@ files:
82
82
  - lib/sentry/rails/tracing/action_view_subscriber.rb
83
83
  - lib/sentry/rails/tracing/active_record_subscriber.rb
84
84
  - lib/sentry/rails/tracing/active_storage_subscriber.rb
85
+ - lib/sentry/rails/tracing/active_support_subscriber.rb
85
86
  - lib/sentry/rails/version.rb
86
87
  - sentry-rails.gemspec
87
- homepage: https://github.com/getsentry/sentry-ruby/tree/5.21.0/sentry-rails
88
+ homepage: https://github.com/getsentry/sentry-ruby/tree/5.22.1/sentry-rails
88
89
  licenses:
89
90
  - MIT
90
91
  metadata:
91
- homepage_uri: https://github.com/getsentry/sentry-ruby/tree/5.21.0/sentry-rails
92
- source_code_uri: https://github.com/getsentry/sentry-ruby/tree/5.21.0/sentry-rails
93
- changelog_uri: https://github.com/getsentry/sentry-ruby/blob/5.21.0/CHANGELOG.md
92
+ homepage_uri: https://github.com/getsentry/sentry-ruby/tree/5.22.1/sentry-rails
93
+ source_code_uri: https://github.com/getsentry/sentry-ruby/tree/5.22.1/sentry-rails
94
+ changelog_uri: https://github.com/getsentry/sentry-ruby/blob/5.22.1/CHANGELOG.md
94
95
  bug_tracker_uri: https://github.com/getsentry/sentry-ruby/issues
95
- documentation_uri: http://www.rubydoc.info/gems/sentry-rails/5.21.0
96
+ documentation_uri: http://www.rubydoc.info/gems/sentry-rails/5.22.1
96
97
  post_install_message:
97
98
  rdoc_options: []
98
99
  require_paths:
@@ -108,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
109
  - !ruby/object:Gem::Version
109
110
  version: '0'
110
111
  requirements: []
111
- rubygems_version: 3.5.16
112
+ rubygems_version: 3.5.22
112
113
  signing_key:
113
114
  specification_version: 4
114
115
  summary: A gem that provides Rails integration for the Sentry error logger