sentry-rails 5.5.0 → 5.6.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: 9a4ffdc16721cf8bcce92afe2355c4f07a764db5dbff66142b784d8364321edf
4
- data.tar.gz: 76a8a3a1575dca6197d90b30b93103a3aaa37eb1fa78ad4f669c8859e49da31c
3
+ metadata.gz: 5bf51e07c223ef36d3cbe5ad72f7dad533159d05c1665b896a068394770327e4
4
+ data.tar.gz: 95c2fefcecd78940fc3e847cff711f855dda399d35adf6a6a343507304cd2e2a
5
5
  SHA512:
6
- metadata.gz: 1ec7bbefeb060dfb8c9c7b9a16e220396b5257fa18e91b32728c1f9ab9d7b724cb23a6ad2704a412c0451d36a390bc7f92b8cf1c1738dc87040b4d7fb5d0f772
7
- data.tar.gz: 8e88a2891b5248c5e34a9ccf977575310ab88347fa3e1a13a23a9fa51c7fe89ef0bba72200417895ac9908c4b47fbef7a854dc8369cbbae973c15086a6de4355
6
+ metadata.gz: cc9954d8ba18402bc7f20e3393d505b4cac9d422e3378261f793a7b19d2e478ca5585a5dd3ef5aa3a44424b84df102262ad63742e30ec31c39efd9b93dcffc66
7
+ data.tar.gz: ea7cb4dbf2f445a69802f8e6d171edebf21617b2fccddfa34152a3d1a90f813dbdd86ad227da328fa1509b8d72e7171375f6f885cc673c53d3afa6bb2864bf0b
@@ -2,6 +2,8 @@ module Sentry
2
2
  module Rails
3
3
  module ActionCableExtensions
4
4
  class ErrorHandler
5
+ OP_NAME = "websocket.server".freeze
6
+
5
7
  class << self
6
8
  def capture(connection, transaction_name:, extra_context: nil, &block)
7
9
  return block.call unless Sentry.initialized?
@@ -33,7 +35,7 @@ module Sentry
33
35
  sentry_trace = env["HTTP_SENTRY_TRACE"]
34
36
  baggage = env["HTTP_BAGGAGE"]
35
37
 
36
- options = { name: scope.transaction_name, source: scope.transaction_source, op: "rails.action_cable".freeze }
38
+ options = { name: scope.transaction_name, source: scope.transaction_source, op: OP_NAME }
37
39
  transaction = Sentry::Transaction.from_sentry_trace(sentry_trace, baggage: baggage, **options) if sentry_trace
38
40
  Sentry.start_transaction(transaction: transaction, **options)
39
41
  end
@@ -16,6 +16,8 @@ module Sentry
16
16
  end
17
17
 
18
18
  class SentryReporter
19
+ OP_NAME = "queue.active_job".freeze
20
+
19
21
  class << self
20
22
  def record(job, &block)
21
23
  Sentry.with_scope do |scope|
@@ -25,7 +27,7 @@ module Sentry
25
27
  if job.is_a?(::Sentry::SendEventJob)
26
28
  nil
27
29
  else
28
- Sentry.start_transaction(name: scope.transaction_name, source: scope.transaction_source, op: "active_job")
30
+ Sentry.start_transaction(name: scope.transaction_name, source: scope.transaction_source, op: OP_NAME)
29
31
  end
30
32
 
31
33
  scope.set_span(transaction) if transaction
@@ -3,8 +3,11 @@ module Sentry
3
3
  def _perform(&block)
4
4
  block.call
5
5
  ensure
6
- # make sure the background worker returns AR connection if it accidentally acquire one during serialization
7
- ActiveRecord::Base.connection_pool.release_connection
6
+ # some applications have partial or even no AR connection
7
+ if ActiveRecord::Base.connected?
8
+ # make sure the background worker returns AR connection if it accidentally acquire one during serialization
9
+ ActiveRecord::Base.connection_pool.release_connection
10
+ end
8
11
  end
9
12
  end
10
13
  end
@@ -1,11 +1,11 @@
1
1
  module Sentry
2
2
  module Rails
3
3
  class CaptureExceptions < Sentry::Rack::CaptureExceptions
4
- def initialize(app)
4
+ def initialize(_)
5
5
  super
6
6
 
7
- if defined?(::Sprockets::Rails)
8
- @assets_regex = %r(\A/{0,2}#{::Rails.application.config.assets.prefix})
7
+ if Sentry.initialized?
8
+ @assets_regexp = Sentry.configuration.rails.assets_regexp
9
9
  end
10
10
  end
11
11
 
@@ -17,7 +17,7 @@ module Sentry
17
17
  end
18
18
 
19
19
  def transaction_op
20
- "rails.request".freeze
20
+ "http.server".freeze
21
21
  end
22
22
 
23
23
  def capture_exception(exception, env)
@@ -36,7 +36,7 @@ module Sentry
36
36
 
37
37
  options = { name: scope.transaction_name, source: scope.transaction_source, op: transaction_op }
38
38
 
39
- if @assets_regex && scope.transaction_name.match?(@assets_regex)
39
+ if @assets_regexp && scope.transaction_name.match?(@assets_regexp)
40
40
  options.merge!(sampled: false)
41
41
  end
42
42
 
@@ -60,10 +60,28 @@ module Sentry
60
60
 
61
61
  attr_accessor :tracing_subscribers
62
62
 
63
+ # sentry-rails by default skips asset request' transactions by checking if the path matches
64
+ #
65
+ # ```rb
66
+ # %r(\A/{0,2}#{::Rails.application.config.assets.prefix})
67
+ # ```
68
+ #
69
+ # If you want to use a different pattern, you can configure the `assets_regexp` option like:
70
+ #
71
+ # ```rb
72
+ # Sentry.init do |config|
73
+ # config.rails.assets_regexp = /my_regexp/
74
+ # end
75
+ # ```
76
+ attr_accessor :assets_regexp
77
+
63
78
  def initialize
64
79
  @register_error_subscriber = false
65
80
  @report_rescued_exceptions = true
66
81
  @skippable_job_adapters = []
82
+ @assets_regexp = if defined?(::Sprockets::Rails)
83
+ %r(\A/{0,2}#{::Rails.application.config.assets.prefix})
84
+ end
67
85
  @tracing_subscribers = Set.new([
68
86
  Sentry::Rails::Tracing::ActionControllerSubscriber,
69
87
  Sentry::Rails::Tracing::ActionViewSubscriber,
@@ -3,7 +3,9 @@ module Sentry
3
3
  module ControllerTransaction
4
4
  def self.included(base)
5
5
  base.prepend_before_action do |controller|
6
- Sentry.get_current_scope.set_transaction_name("#{controller.class}##{controller.action_name}", source: :view)
6
+ if Sentry.initialized?
7
+ Sentry.get_current_scope.set_transaction_name("#{controller.class}##{controller.action_name}", source: :view)
8
+ end
7
9
  end
8
10
  end
9
11
  end
@@ -8,6 +8,7 @@ module Sentry
8
8
  extend InstrumentPayloadCleanupHelper
9
9
 
10
10
  EVENT_NAMES = ["process_action.action_controller"].freeze
11
+ OP_NAME = "view.process_action.action_controller".freeze
11
12
 
12
13
  def self.subscribe!
13
14
  subscribe_to_event(EVENT_NAMES) do |event_name, duration, payload|
@@ -15,7 +16,7 @@ module Sentry
15
16
  action = payload[:action]
16
17
 
17
18
  record_on_current_span(
18
- op: event_name,
19
+ op: OP_NAME,
19
20
  start_timestamp: payload[START_TIMESTAMP_NAME],
20
21
  description: "#{controller}##{action}",
21
22
  duration: duration
@@ -21,7 +21,7 @@ module Sentry
21
21
 
22
22
  def self.subscribe!
23
23
  subscribe_to_event(EVENT_NAMES) do |event_name, duration, payload|
24
- record_on_current_span(op: event_name, start_timestamp: payload[START_TIMESTAMP_NAME], description: payload[:service], duration: duration) do |span|
24
+ record_on_current_span(op: "file.#{event_name}".freeze, start_timestamp: payload[START_TIMESTAMP_NAME], description: payload[:service], duration: duration) do |span|
25
25
  payload.each do |key, value|
26
26
  span.set_data(key, value) unless key == START_TIMESTAMP_NAME
27
27
  end
@@ -67,7 +67,7 @@ module Sentry
67
67
  end
68
68
 
69
69
  def self.get_current_transaction
70
- Sentry.get_current_scope.get_transaction
70
+ Sentry.get_current_scope.get_transaction if Sentry.initialized?
71
71
  end
72
72
 
73
73
  # it's just a container for the extended method
@@ -1,5 +1,5 @@
1
1
  module Sentry
2
2
  module Rails
3
- VERSION = "5.5.0"
3
+ VERSION = "5.6.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.5.0"
26
+ spec.add_dependency "sentry-ruby", "~> 5.6.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.5.0
4
+ version: 5.6.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-10-03 00:00:00.000000000 Z
11
+ date: 2022-11-08 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.5.0
33
+ version: 5.6.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.5.0
40
+ version: 5.6.0
41
41
  description: A gem that provides Rails integration for the Sentry error logger
42
42
  email: accounts@sentry.io
43
43
  executables: []