sentry-ruby-core 5.17.1 → 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: 0cae396d3892787f7367cea0f73be32f9760efb811bae3a182a09353bbcf3b24
4
- data.tar.gz: 37165f9ec11f6a8d5ab00e8638064cb4ef288f5103d511ae8d462deda44c5147
3
+ metadata.gz: be9c1bd29350d0e6a59ee415c3ab1b2509172c9e6e566b3c2bdcd013c80fc8cf
4
+ data.tar.gz: 39b5b3fe8b54be43ecfd06cc39981e670a9c07d86d303a412aa4d83577155513
5
5
  SHA512:
6
- metadata.gz: 96df11cd0861fdc096641b4cf88f5be36b626214c5312ef7570da8567125b517394d99c6a5601f7f25f5a6871d6918cd8f3d6918b63ff54d8b732b19bb9ea39b
7
- data.tar.gz: 6f39a9d62409c34d0f3a3d6e72614f509899c642d7303ea041f7620c5b753b38fd2acd3a84eb9b7758a33548d8055fb53e24b5d365dd997ae6ccb5054ff22fb9
6
+ metadata.gz: 7efacb821bec171862390a6cda4353a94a32cdb064b63eb4b6b665a52798fa7338dd41df5648e6e32a5f45311455f13eb69cf8a852d197c44863aa16adc6dce1
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
@@ -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.1"
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-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.17.1
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-15 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: sentry-ruby
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 5.17.1
19
+ version: 5.17.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 5.17.1
26
+ version: 5.17.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: concurrent-ruby
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -83,6 +83,7 @@ files:
83
83
  - lib/sentry/integrable.rb
84
84
  - lib/sentry/interface.rb
85
85
  - lib/sentry/interfaces/exception.rb
86
+ - lib/sentry/interfaces/mechanism.rb
86
87
  - lib/sentry/interfaces/request.rb
87
88
  - lib/sentry/interfaces/single_exception.rb
88
89
  - lib/sentry/interfaces/stacktrace.rb