sentry-ruby-core 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 +4 -4
- data/lib/sentry/client.rb +2 -1
- data/lib/sentry/error_event.rb +2 -2
- data/lib/sentry/hub.rb +1 -1
- data/lib/sentry/integrable.rb +4 -0
- data/lib/sentry/interface.rb +1 -0
- data/lib/sentry/interfaces/exception.rb +4 -3
- data/lib/sentry/interfaces/mechanism.rb +20 -0
- data/lib/sentry/interfaces/single_exception.rb +6 -4
- data/lib/sentry/rack/capture_exceptions.rb +6 -1
- data/lib/sentry/rake.rb +3 -1
- data/lib/sentry/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be9c1bd29350d0e6a59ee415c3ab1b2509172c9e6e566b3c2bdcd013c80fc8cf
|
4
|
+
data.tar.gz: 39b5b3fe8b54be43ecfd06cc39981e670a9c07d86d303a412aa4d83577155513
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/sentry/error_event.rb
CHANGED
@@ -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
data/lib/sentry/integrable.rb
CHANGED
@@ -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
|
|
data/lib/sentry/interface.rb
CHANGED
@@ -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.
|
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)
|
data/lib/sentry/version.rb
CHANGED
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.
|
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
|
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.
|
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.
|
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
|