sentry-rails 5.9.0 → 5.11.0

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: 93209fe5a0b0e76d0260c3355410492f36d8d72ef4f4852b4345d80656eb9dc6
4
- data.tar.gz: e67e804834d28db4c5237757caffded4856d6a9594f337b2412e76c874a1cd58
3
+ metadata.gz: 39ae75bb0a992ced9247272ab6d20ff61aee51ee2a9a02f309204fb01533aae3
4
+ data.tar.gz: 6a00192e48a695c90ed994ccdb40cc4def17c1263c1c469d2c7daac5f933607b
5
5
  SHA512:
6
- metadata.gz: eadf2d1e97b5ab7a6abf9fdc03609bf1c362e1ebba96b369f895c04a8d8341acbb2d3f121c1d03420fbcb32083abc1a07489a1f1b12b02c99b8b4c8bebfdbd41
7
- data.tar.gz: 1c71775f931fd3b08a7dc1567a3baff47d6c56a128f34e5eb8ab42be9c1b89fae3e2201feba4e495e09e1fb8a343039ce4be3ccdc88bcea9ed63c6b024366a06
6
+ metadata.gz: a99466d8bbab1261f08b0bdf2a1394e5dfb473fc53e9f4af91fb67411ef668c2e49c26496be127a7e2f5350c4d745388eddb0f357963caafe966a77cc8ce3028
7
+ data.tar.gz: 33f3d414890890cda3529d8f21f916f74db743ce466b8fc7f70a1529a659d1be6360f6e98097ddf30ea896c8d85c497acd2e73c1831d1025fcc669f56f6562e5
data/Gemfile CHANGED
@@ -5,13 +5,15 @@ git_source(:github) { |name| "https://github.com/#{name}.git" }
5
5
  gemspec
6
6
  gem "sentry-ruby", path: "../sentry-ruby"
7
7
 
8
+ platform :jruby do
9
+ gem 'activerecord-jdbcmysql-adapter'
10
+ gem "jdbc-sqlite3"
11
+ end
12
+
8
13
  rails_version = ENV["RAILS_VERSION"]
9
14
  rails_version = "7.0.0" if rails_version.nil?
10
15
  rails_version = Gem::Version.new(rails_version)
11
16
 
12
- gem 'activerecord-jdbcmysql-adapter', platform: :jruby
13
- gem "jdbc-sqlite3", platform: :jruby
14
-
15
17
  if rails_version < Gem::Version.new("6.0.0")
16
18
  gem "sqlite3", "~> 1.3.0", platform: :ruby
17
19
  else
@@ -37,10 +39,22 @@ gem 'simplecov'
37
39
  gem "simplecov-cobertura", "~> 1.4"
38
40
  gem "rexml"
39
41
 
42
+ # https://github.com/flavorjones/loofah/pull/267
43
+ # loofah changed the required ruby version in a patch so we need to explicitly pin it
44
+ gem "loofah", "2.20.0" if RUBY_VERSION.to_f < 2.5
45
+
40
46
  gem "rake", "~> 12.0"
41
47
 
42
- gem "object_tracer"
43
- gem "debug", github: "ruby/debug", platform: :ruby if RUBY_VERSION.to_f >= 2.6
48
+ if RUBY_VERSION.to_f >= 2.6
49
+ gem "debug", github: "ruby/debug", platform: :ruby
50
+
51
+ if rails_version == Gem::Version.new("6.0.0") && RUBY_VERSION.to_f == 2.7
52
+ gem "irb", "~> 1.7.4" # irb 1.8 adds psych via rdoc that causes CI to fail
53
+ else
54
+ gem "irb"
55
+ end
56
+ end
57
+
44
58
  gem "pry"
45
59
 
46
60
  gem "benchmark-ips"
@@ -33,11 +33,8 @@ module Sentry
33
33
  end
34
34
 
35
35
  def start_transaction(env, scope)
36
- sentry_trace = env["HTTP_SENTRY_TRACE"]
37
- baggage = env["HTTP_BAGGAGE"]
38
-
39
36
  options = { name: scope.transaction_name, source: scope.transaction_source, op: OP_NAME }
40
- transaction = Sentry::Transaction.from_sentry_trace(sentry_trace, baggage: baggage, **options) if sentry_trace
37
+ transaction = Sentry.continue_trace(env, **options)
41
38
  Sentry.start_transaction(transaction: transaction, **options)
42
39
  end
43
40
 
@@ -1,20 +1,76 @@
1
- require "sentry/rails/instrument_payload_cleanup_helper"
2
-
3
1
  module Sentry
4
2
  module Rails
5
3
  module Breadcrumb
6
4
  module ActiveSupportLogger
7
- class << self
8
- include InstrumentPayloadCleanupHelper
5
+ ALLOWED_LIST = {
6
+ # action_controller
7
+ "write_fragment.action_controller" => %i[key],
8
+ "read_fragment.action_controller" => %i[key],
9
+ "exist_fragment?.action_controller" => %i[key],
10
+ "expire_fragment.action_controller" => %i[key],
11
+ "start_processing.action_controller" => %i[controller action params format method path],
12
+ "process_action.action_controller" => %i[controller action params format method path status view_runtime db_runtime],
13
+ "send_file.action_controller" => %i[path],
14
+ "redirect_to.action_controller" => %i[status location],
15
+ "halted_callback.action_controller" => %i[filter],
16
+ # action_dispatch
17
+ "process_middleware.action_dispatch" => %i[middleware],
18
+ # action_view
19
+ "render_template.action_view" => %i[identifier layout],
20
+ "render_partial.action_view" => %i[identifier],
21
+ "render_collection.action_view" => %i[identifier count cache_hits],
22
+ "render_layout.action_view" => %i[identifier],
23
+ # active_record
24
+ "sql.active_record" => %i[sql name statement_name cached],
25
+ "instantiation.active_record" => %i[record_count class_name],
26
+ # action_mailer
27
+ # not including to, from, or subject..etc. because of PII concern
28
+ "deliver.action_mailer" => %i[mailer date perform_deliveries],
29
+ "process.action_mailer" => %i[mailer action params],
30
+ # active_support
31
+ "cache_read.active_support" => %i[key store hit],
32
+ "cache_generate.active_support" => %i[key store],
33
+ "cache_fetch_hit.active_support" => %i[key store],
34
+ "cache_write.active_support" => %i[key store],
35
+ "cache_delete.active_support" => %i[key store],
36
+ "cache_exist?.active_support" => %i[key store],
37
+ # active_job
38
+ "enqueue_at.active_job" => %i[],
39
+ "enqueue.active_job" => %i[],
40
+ "enqueue_retry.active_job" => %i[],
41
+ "perform_start.active_job" => %i[],
42
+ "perform.active_job" => %i[],
43
+ "retry_stopped.active_job" => %i[],
44
+ "discard.active_job" => %i[],
45
+ # action_cable
46
+ "perform_action.action_cable" => %i[channel_class action],
47
+ "transmit.action_cable" => %i[channel_class],
48
+ "transmit_subscription_confirmation.action_cable" => %i[channel_class],
49
+ "transmit_subscription_rejection.action_cable" => %i[channel_class],
50
+ "broadcast.action_cable" => %i[broadcasting],
51
+ # active_storage
52
+ "service_upload.active_storage" => %i[service key checksum],
53
+ "service_streaming_download.active_storage" => %i[service key],
54
+ "service_download_chunk.active_storage" => %i[service key],
55
+ "service_download.active_storage" => %i[service key],
56
+ "service_delete.active_storage" => %i[service key],
57
+ "service_delete_prefixed.active_storage" => %i[service prefix],
58
+ "service_exist.active_storage" => %i[service key exist],
59
+ "service_url.active_storage" => %i[service key url],
60
+ "service_update_metadata.active_storage" => %i[service key],
61
+ "preview.active_storage" => %i[key],
62
+ "analyze.active_storage" => %i[analyzer],
63
+ }.freeze
9
64
 
65
+ class << self
10
66
  def add(name, started, _finished, _unique_id, data)
11
67
  # skip Rails' internal events
12
68
  return if name.start_with?("!")
13
69
 
70
+ allowed_keys = ALLOWED_LIST[name]
71
+
14
72
  if data.is_a?(Hash)
15
- # we should only mutate the copy of the data
16
- data = data.dup
17
- cleanup_data(data)
73
+ data = data.slice(*allowed_keys)
18
74
  end
19
75
 
20
76
  crumb = Sentry::Breadcrumb.new(
@@ -1,6 +1,8 @@
1
1
  module Sentry
2
2
  module Rails
3
3
  class CaptureExceptions < Sentry::Rack::CaptureExceptions
4
+ RAILS_7_1 = Gem::Version.new(::Rails.version) >= Gem::Version.new("7.1.0.alpha")
5
+
4
6
  def initialize(_)
5
7
  super
6
8
 
@@ -21,28 +23,34 @@ module Sentry
21
23
  end
22
24
 
23
25
  def capture_exception(exception, env)
24
- request = ActionDispatch::Request.new(env)
25
-
26
26
  # the exception will be swallowed by ShowExceptions middleware
27
- return if request.show_exceptions? && !Sentry.configuration.rails.report_rescued_exceptions
27
+ return if show_exceptions?(exception, env) && !Sentry.configuration.rails.report_rescued_exceptions
28
+
28
29
  Sentry::Rails.capture_exception(exception).tap do |event|
29
30
  env[ERROR_EVENT_ID_KEY] = event.event_id if event
30
31
  end
31
32
  end
32
33
 
33
34
  def start_transaction(env, scope)
34
- sentry_trace = env["HTTP_SENTRY_TRACE"]
35
- baggage = env["HTTP_BAGGAGE"]
36
-
37
35
  options = { name: scope.transaction_name, source: scope.transaction_source, op: transaction_op }
38
36
 
39
37
  if @assets_regexp && scope.transaction_name.match?(@assets_regexp)
40
38
  options.merge!(sampled: false)
41
39
  end
42
40
 
43
- transaction = Sentry::Transaction.from_sentry_trace(sentry_trace, baggage: baggage, **options) if sentry_trace
41
+ transaction = Sentry.continue_trace(env, **options)
44
42
  Sentry.start_transaction(transaction: transaction, custom_sampling_context: { env: env }, **options)
45
43
  end
44
+
45
+ def show_exceptions?(exception, env)
46
+ request = ActionDispatch::Request.new(env)
47
+
48
+ if RAILS_7_1
49
+ ActionDispatch::ExceptionWrapper.new(nil, exception).show?(request)
50
+ else
51
+ request.show_exceptions?
52
+ end
53
+ end
46
54
  end
47
55
  end
48
56
  end
@@ -12,7 +12,7 @@ module Sentry
12
12
  @excluded_exceptions = @excluded_exceptions.concat(Sentry::Rails::IGNORE_DEFAULT)
13
13
 
14
14
  if ::Rails.logger
15
- @logger = ::Rails.logger
15
+ @logger = ::Rails.logger.dup
16
16
  else
17
17
  @logger.warn(Sentry::LOGGER_PROGNAME) do
18
18
  <<~MSG
@@ -13,8 +13,31 @@ module Sentry
13
13
  next if EXCLUDED_EVENTS.include? payload[:name]
14
14
 
15
15
  record_on_current_span(op: SPAN_PREFIX + event_name, start_timestamp: payload[START_TIMESTAMP_NAME], description: payload[:sql], duration: duration) do |span|
16
- span.set_data(:connection_id, payload[:connection_id])
17
16
  span.set_tag(:cached, true) if payload.fetch(:cached, false) # cached key is only set for hits in the QueryCache, from Rails 5.1
17
+
18
+ connection = payload[:connection]
19
+
20
+ if payload[:connection_id]
21
+ span.set_data(:connection_id, payload[:connection_id])
22
+
23
+ # we fallback to the base connection on rails < 6.0.0 since the payload doesn't have it
24
+ base_connection = ActiveRecord::Base.connection
25
+ connection ||= base_connection if payload[:connection_id] == base_connection.object_id
26
+ end
27
+
28
+ next unless connection
29
+
30
+ db_config = if connection.pool.respond_to?(:db_config)
31
+ connection.pool.db_config.configuration_hash
32
+ elsif connection.pool.respond_to?(:spec)
33
+ connection.pool.spec.config
34
+ end
35
+
36
+ span.set_data(Span::DataConventions::DB_SYSTEM, db_config[:adapter]) if db_config[:adapter]
37
+ span.set_data(Span::DataConventions::DB_NAME, db_config[:database]) if db_config[:database]
38
+ span.set_data(Span::DataConventions::SERVER_ADDRESS, db_config[:host]) if db_config[:host]
39
+ span.set_data(Span::DataConventions::SERVER_PORT, db_config[:port]) if db_config[:port]
40
+ span.set_data(Span::DataConventions::SERVER_SOCKET_ADDRESS, db_config[:socket]) if db_config[:socket]
18
41
  end
19
42
  end
20
43
  end
@@ -1,5 +1,5 @@
1
1
  module Sentry
2
2
  module Rails
3
- VERSION = "5.9.0"
3
+ VERSION = "5.11.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", "~> 5.9.0"
26
+ spec.add_dependency "sentry-ruby", "~> 5.11.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: 5.9.0
4
+ version: 5.11.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: 2023-04-19 00:00:00.000000000 Z
11
+ date: 2023-09-06 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.9.0
33
+ version: 5.11.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: 5.9.0
40
+ version: 5.11.0
41
41
  description: A gem that provides Rails integration for the Sentry error logger
42
42
  email: accounts@sentry.io
43
43
  executables: []
@@ -49,7 +49,6 @@ files:
49
49
  - ".gitignore"
50
50
  - ".rspec"
51
51
  - CHANGELOG.md
52
- - CODE_OF_CONDUCT.md
53
52
  - Gemfile
54
53
  - LICENSE.txt
55
54
  - Makefile
data/CODE_OF_CONDUCT.md DELETED
@@ -1,74 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- In the interest of fostering an open and welcoming environment, we as
6
- contributors and maintainers pledge to making participation in our project and
7
- our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, gender identity and expression, level of experience,
9
- nationality, personal appearance, race, religion, or sexual identity and
10
- orientation.
11
-
12
- ## Our Standards
13
-
14
- Examples of behavior that contributes to creating a positive environment
15
- include:
16
-
17
- * Using welcoming and inclusive language
18
- * Being respectful of differing viewpoints and experiences
19
- * Gracefully accepting constructive criticism
20
- * Focusing on what is best for the community
21
- * Showing empathy towards other community members
22
-
23
- Examples of unacceptable behavior by participants include:
24
-
25
- * The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
27
- * Trolling, insulting/derogatory comments, and personal or political attacks
28
- * Public or private harassment
29
- * Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
31
- * Other conduct which could reasonably be considered inappropriate in a
32
- professional setting
33
-
34
- ## Our Responsibilities
35
-
36
- Project maintainers are responsible for clarifying the standards of acceptable
37
- behavior and are expected to take appropriate and fair corrective action in
38
- response to any instances of unacceptable behavior.
39
-
40
- Project maintainers have the right and responsibility to remove, edit, or
41
- reject comments, commits, code, wiki edits, issues, and other contributions
42
- that are not aligned to this Code of Conduct, or to ban temporarily or
43
- permanently any contributor for other behaviors that they deem inappropriate,
44
- threatening, offensive, or harmful.
45
-
46
- ## Scope
47
-
48
- This Code of Conduct applies both within project spaces and in public spaces
49
- when an individual is representing the project or its community. Examples of
50
- representing a project or community include using an official project e-mail
51
- address, posting via an official social media account, or acting as an appointed
52
- representative at an online or offline event. Representation of a project may be
53
- further defined and clarified by project maintainers.
54
-
55
- ## Enforcement
56
-
57
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at stan001212@gmail.com. All
59
- complaints will be reviewed and investigated and will result in a response that
60
- is deemed necessary and appropriate to the circumstances. The project team is
61
- obligated to maintain confidentiality with regard to the reporter of an incident.
62
- Further details of specific enforcement policies may be posted separately.
63
-
64
- Project maintainers who do not follow or enforce the Code of Conduct in good
65
- faith may face temporary or permanent repercussions as determined by other
66
- members of the project's leadership.
67
-
68
- ## Attribution
69
-
70
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at [https://contributor-covenant.org/version/1/4][version]
72
-
73
- [homepage]: https://contributor-covenant.org
74
- [version]: https://contributor-covenant.org/version/1/4/