sentry-ruby 5.17.0 → 5.17.2

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: 92411c3edf0e7dfd2bf84109e80a2129fc914a9c5ce153416d42ebcf46081c1e
4
- data.tar.gz: b180050dc794fad86f9a8c098ef2bb96bb3ba47cd09c854ebe24e52d986e2217
3
+ metadata.gz: de5757f08dbb0987ccfc9e447f482358722a3684abae2ee581ab03a6bb290418
4
+ data.tar.gz: 39b5b3fe8b54be43ecfd06cc39981e670a9c07d86d303a412aa4d83577155513
5
5
  SHA512:
6
- metadata.gz: b8ed1dbfb63041f9e73bb0f98fddf41b35a7da81ee747bbd0b5b60448d923e642cd4f299f8f12b190766132b5d6061352341e28b2abdc7196eeea5522617b1c5
7
- data.tar.gz: 966f1db9b038e31381521217ad0bde4cc35552c0b4a35795d5871b6f5c9d97f4d04fe052e8b825897b22cbe63da84719e8b101634ec8fea3677b0d5155cd39eb
6
+ metadata.gz: 034a330fcb4e8d1722eadcba6dbf6cf69f02919555f255ca98493ade5ebc2441a5b15bb6ce9bc3f2a6305b05e867f2a1e87f7eedc7b0a029036d4939a715ff69
7
+ data.tar.gz: d75b0125443e8cff217fc1c4a6c9ff5dc1ff7ee51542e19ab3d3768e2f716233196afdcc72883b9b451d42817bd7a974c73095c27b48abfaffa089ae9a78d066
data/lib/sentry/client.rb CHANGED
@@ -88,9 +88,10 @@ module Sentry
88
88
  return if !ignore_exclusions && !@configuration.exception_class_allowed?(exception)
89
89
 
90
90
  integration_meta = Sentry.integrations[hint[:integration]]
91
+ mechanism = hint.delete(:mechanism) { Mechanism.new }
91
92
 
92
93
  ErrorEvent.new(configuration: configuration, integration_meta: integration_meta).tap do |event|
93
- event.add_exception_interface(exception)
94
+ event.add_exception_interface(exception, mechanism: mechanism)
94
95
  event.add_threads_interface(crashed: true)
95
96
  event.level = :error
96
97
  end
@@ -27,12 +27,12 @@ module Sentry
27
27
  end
28
28
 
29
29
  # @!visibility private
30
- def add_exception_interface(exception)
30
+ def add_exception_interface(exception, mechanism:)
31
31
  if exception.respond_to?(:sentry_context)
32
32
  @extra.merge!(exception.sentry_context)
33
33
  end
34
34
 
35
- @exception = Sentry::ExceptionInterface.build(exception: exception, stacktrace_builder: @stacktrace_builder)
35
+ @exception = Sentry::ExceptionInterface.build(exception: exception, stacktrace_builder: @stacktrace_builder, mechanism: mechanism)
36
36
  end
37
37
  end
38
38
  end
data/lib/sentry/hub.rb CHANGED
@@ -245,7 +245,7 @@ module Sentry
245
245
  end
246
246
 
247
247
  def with_session_tracking(&block)
248
- return yield unless configuration.auto_session_tracking
248
+ return yield unless configuration.session_tracking?
249
249
 
250
250
  start_session
251
251
  yield
@@ -14,6 +14,10 @@ module Sentry
14
14
  def capture_exception(exception, **options, &block)
15
15
  options[:hint] ||= {}
16
16
  options[:hint][:integration] = integration_name
17
+
18
+ # within an integration, we usually intercept uncaught exceptions so we set handled to false.
19
+ options[:hint][:mechanism] ||= Sentry::Mechanism.new(type: integration_name, handled: false)
20
+
17
21
  Sentry.capture_exception(exception, **options, &block)
18
22
  end
19
23
 
@@ -14,3 +14,4 @@ require "sentry/interfaces/request"
14
14
  require "sentry/interfaces/single_exception"
15
15
  require "sentry/interfaces/stacktrace"
16
16
  require "sentry/interfaces/threads"
17
+ require "sentry/interfaces/mechanism"
@@ -24,17 +24,18 @@ module Sentry
24
24
  # @param stacktrace_builder [StacktraceBuilder]
25
25
  # @see SingleExceptionInterface#build_with_stacktrace
26
26
  # @see SingleExceptionInterface#initialize
27
+ # @param mechanism [Mechanism]
27
28
  # @return [ExceptionInterface]
28
- def self.build(exception:, stacktrace_builder:)
29
+ def self.build(exception:, stacktrace_builder:, mechanism:)
29
30
  exceptions = Sentry::Utils::ExceptionCauseChain.exception_to_array(exception).reverse
30
31
  processed_backtrace_ids = Set.new
31
32
 
32
33
  exceptions = exceptions.map do |e|
33
34
  if e.backtrace && !processed_backtrace_ids.include?(e.backtrace.object_id)
34
35
  processed_backtrace_ids << e.backtrace.object_id
35
- SingleExceptionInterface.build_with_stacktrace(exception: e, stacktrace_builder: stacktrace_builder)
36
+ SingleExceptionInterface.build_with_stacktrace(exception: e, stacktrace_builder: stacktrace_builder, mechanism: mechanism)
36
37
  else
37
- SingleExceptionInterface.new(exception: exception)
38
+ SingleExceptionInterface.new(exception: exception, mechanism: mechanism)
38
39
  end
39
40
  end
40
41
 
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Sentry
4
+ class Mechanism < Interface
5
+ # Generic identifier, mostly the source integration for this exception.
6
+ # @return [String]
7
+ attr_accessor :type
8
+
9
+ # A manually captured exception has handled set to true,
10
+ # false if coming from an integration where we intercept an uncaught exception.
11
+ # Defaults to true here and will be set to false explicitly in integrations.
12
+ # @return [Boolean]
13
+ attr_accessor :handled
14
+
15
+ def initialize(type: 'generic', handled: true)
16
+ @type = type
17
+ @handled = handled
18
+ end
19
+ end
20
+ end
@@ -11,10 +11,10 @@ module Sentry
11
11
  OMISSION_MARK = "...".freeze
12
12
  MAX_LOCAL_BYTES = 1024
13
13
 
14
- attr_reader :type, :module, :thread_id, :stacktrace
14
+ attr_reader :type, :module, :thread_id, :stacktrace, :mechanism
15
15
  attr_accessor :value
16
16
 
17
- def initialize(exception:, stacktrace: nil)
17
+ def initialize(exception:, mechanism:, stacktrace: nil)
18
18
  @type = exception.class.to_s
19
19
  exception_message =
20
20
  if exception.respond_to?(:detailed_message)
@@ -29,17 +29,19 @@ module Sentry
29
29
  @module = exception.class.to_s.split('::')[0...-1].join('::')
30
30
  @thread_id = Thread.current.object_id
31
31
  @stacktrace = stacktrace
32
+ @mechanism = mechanism
32
33
  end
33
34
 
34
35
  def to_hash
35
36
  data = super
36
37
  data[:stacktrace] = data[:stacktrace].to_hash if data[:stacktrace]
38
+ data[:mechanism] = data[:mechanism].to_hash
37
39
  data
38
40
  end
39
41
 
40
42
  # patch this method if you want to change an exception's stacktrace frames
41
43
  # also see `StacktraceBuilder.build`.
42
- def self.build_with_stacktrace(exception:, stacktrace_builder:)
44
+ def self.build_with_stacktrace(exception:, stacktrace_builder:, mechanism:)
43
45
  stacktrace = stacktrace_builder.build(backtrace: exception.backtrace)
44
46
 
45
47
  if locals = exception.instance_variable_get(:@sentry_locals)
@@ -61,7 +63,7 @@ module Sentry
61
63
  stacktrace.frames.last.vars = locals
62
64
  end
63
65
 
64
- new(exception: exception, stacktrace: stacktrace)
66
+ new(exception: exception, stacktrace: stacktrace, mechanism: mechanism)
65
67
  end
66
68
  end
67
69
  end
@@ -4,6 +4,7 @@ module Sentry
4
4
  module Rack
5
5
  class CaptureExceptions
6
6
  ERROR_EVENT_ID_KEY = "sentry.error_event_id"
7
+ MECHANISM_TYPE = "rack"
7
8
 
8
9
  def initialize(app)
9
10
  @app = app
@@ -56,7 +57,7 @@ module Sentry
56
57
  end
57
58
 
58
59
  def capture_exception(exception, env)
59
- Sentry.capture_exception(exception).tap do |event|
60
+ Sentry.capture_exception(exception, hint: { mechanism: mechanism }).tap do |event|
60
61
  env[ERROR_EVENT_ID_KEY] = event.event_id if event
61
62
  end
62
63
  end
@@ -74,6 +75,10 @@ module Sentry
74
75
  transaction.set_http_status(status_code)
75
76
  transaction.finish
76
77
  end
78
+
79
+ def mechanism
80
+ Sentry::Mechanism.new(type: MECHANISM_TYPE, handled: false)
81
+ end
77
82
  end
78
83
  end
79
84
  end
data/lib/sentry/rake.rb CHANGED
@@ -8,7 +8,9 @@ module Sentry
8
8
  module Application
9
9
  # @api private
10
10
  def display_error_message(ex)
11
- Sentry.capture_exception(ex) do |scope|
11
+ mechanism = Sentry::Mechanism.new(type: 'rake', handled: false)
12
+
13
+ Sentry.capture_exception(ex, hint: { mechanism: mechanism }) do |scope|
12
14
  task_name = top_level_tasks.join(' ')
13
15
  scope.set_transaction_name(task_name, source: :task)
14
16
  scope.set_tag("rake_task", task_name)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sentry
4
- VERSION = "5.17.0"
4
+ VERSION = "5.17.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sentry-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.17.0
4
+ version: 5.17.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sentry Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-13 00:00:00.000000000 Z
11
+ date: 2024-04-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -89,6 +89,7 @@ files:
89
89
  - lib/sentry/integrable.rb
90
90
  - lib/sentry/interface.rb
91
91
  - lib/sentry/interfaces/exception.rb
92
+ - lib/sentry/interfaces/mechanism.rb
92
93
  - lib/sentry/interfaces/request.rb
93
94
  - lib/sentry/interfaces/single_exception.rb
94
95
  - lib/sentry/interfaces/stacktrace.rb