sentry-ruby 4.1.1 → 4.1.2
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 +4 -4
- data/CHANGELOG.md +8 -1
- data/Gemfile +1 -1
- data/lib/sentry-ruby.rb +11 -0
- data/lib/sentry/client.rb +9 -5
- data/lib/sentry/event.rb +2 -2
- data/lib/sentry/hub.rb +5 -5
- data/lib/sentry/integrable.rb +24 -0
- data/lib/sentry/rack/capture_exceptions.rb +11 -3
- data/lib/sentry/span.rb +1 -1
- data/lib/sentry/transport.rb +3 -2
- data/lib/sentry/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbe0af63148c410c71208f7bac743d24e224b5265102d645831a9538262961dc
|
4
|
+
data.tar.gz: 9933997d430fc94d400f97b9e2319ab14ccfe1bd2ff42635eda5b13bd4e11621
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a813b4fad61840a850b6dd82451d689272800b5d4e405ab50f80f99cfe69a371f770c1a8151491ccd2f10400822e0e4a98bc8c2ca1265b562139bd7ffc1cdd02
|
7
|
+
data.tar.gz: 1331331801ea39234c96e50e9fc469713efd48ee316e5620ae2c200f97a4a4d88810f942d707fb77dab7b458284ee11cad4b6153632cde4aa6014e2df5a89820
|
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,17 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 4.1.2
|
4
|
+
|
5
|
+
- before_send callback shouldn't be applied to transaction events [#1167](https://github.com/getsentry/sentry-ruby/pull/1167)
|
6
|
+
- Transaction improvements [#1170](https://github.com/getsentry/sentry-ruby/pull/1170)
|
7
|
+
- Support Ruby 3 [#1172](https://github.com/getsentry/sentry-ruby/pull/1172)
|
8
|
+
- Add Integrable module [#1177](https://github.com/getsentry/sentry-ruby/pull/1177)
|
9
|
+
|
3
10
|
## 4.1.1
|
4
11
|
|
5
12
|
- Fix NoMethodError when sending is not allowed [#1161](https://github.com/getsentry/sentry-ruby/pull/1161)
|
6
13
|
- Add notification for users who still use deprecated middlewares [#1160](https://github.com/getsentry/sentry-ruby/pull/1160)
|
7
|
-
- Improve top-level api safety [#
|
14
|
+
- Improve top-level api safety [#1162](https://github.com/getsentry/sentry-ruby/pull/1162)
|
8
15
|
|
9
16
|
## 4.1.0
|
10
17
|
|
data/Gemfile
CHANGED
data/lib/sentry-ruby.rb
CHANGED
@@ -40,6 +40,17 @@ module Sentry
|
|
40
40
|
Time.now.utc
|
41
41
|
end
|
42
42
|
|
43
|
+
class << self
|
44
|
+
def integrations
|
45
|
+
@integrations ||= {}
|
46
|
+
end
|
47
|
+
|
48
|
+
def register_integration(name, version)
|
49
|
+
meta = { name: "sentry.ruby.#{name}", version: version }.freeze
|
50
|
+
integrations[name.to_s] = meta
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
43
54
|
class << self
|
44
55
|
extend Forwardable
|
45
56
|
|
data/lib/sentry/client.rb
CHANGED
@@ -47,16 +47,18 @@ module Sentry
|
|
47
47
|
event
|
48
48
|
end
|
49
49
|
|
50
|
-
def event_from_exception(exception)
|
50
|
+
def event_from_exception(exception, hint = {})
|
51
|
+
integration_meta = Sentry.integrations[hint[:integration]]
|
51
52
|
return unless @configuration.exception_class_allowed?(exception)
|
52
53
|
|
53
|
-
Event.new(configuration: configuration).tap do |event|
|
54
|
+
Event.new(configuration: configuration, integration_meta: integration_meta).tap do |event|
|
54
55
|
event.add_exception_interface(exception)
|
55
56
|
end
|
56
57
|
end
|
57
58
|
|
58
|
-
def event_from_message(message)
|
59
|
-
|
59
|
+
def event_from_message(message, hint = {})
|
60
|
+
integration_meta = Sentry.integrations[hint[:integration]]
|
61
|
+
Event.new(configuration: configuration, integration_meta: integration_meta, message: message)
|
60
62
|
end
|
61
63
|
|
62
64
|
def event_from_transaction(transaction)
|
@@ -72,7 +74,9 @@ module Sentry
|
|
72
74
|
end
|
73
75
|
|
74
76
|
def send_event(event, hint = nil)
|
75
|
-
|
77
|
+
event_type = event.is_a?(Event) ? event.type : event["type"]
|
78
|
+
event = configuration.before_send.call(event, hint) if configuration.before_send && event_type == "event"
|
79
|
+
|
76
80
|
if event.nil?
|
77
81
|
configuration.logger.info(LOGGER_PROGNAME) { "Discarded event because before_send returned nil" }
|
78
82
|
return
|
data/lib/sentry/event.rb
CHANGED
@@ -20,7 +20,7 @@ module Sentry
|
|
20
20
|
attr_accessor(*ATTRIBUTES)
|
21
21
|
attr_reader :configuration, :request, :exception, :stacktrace
|
22
22
|
|
23
|
-
def initialize(configuration:, message: nil)
|
23
|
+
def initialize(configuration:, integration_meta: nil, message: nil)
|
24
24
|
# this needs to go first because some setters rely on configuration
|
25
25
|
@configuration = configuration
|
26
26
|
|
@@ -28,7 +28,7 @@ module Sentry
|
|
28
28
|
@event_id = SecureRandom.uuid.delete("-")
|
29
29
|
@timestamp = Sentry.utc_now.iso8601
|
30
30
|
@platform = :ruby
|
31
|
-
@sdk = Sentry.sdk_meta
|
31
|
+
@sdk = integration_meta || Sentry.sdk_meta
|
32
32
|
|
33
33
|
@user = {}
|
34
34
|
@extra = {}
|
data/lib/sentry/hub.rb
CHANGED
@@ -76,12 +76,12 @@ module Sentry
|
|
76
76
|
def capture_exception(exception, **options, &block)
|
77
77
|
return unless current_client
|
78
78
|
|
79
|
-
|
79
|
+
options[:hint] ||= {}
|
80
|
+
options[:hint][:exception] = exception
|
81
|
+
event = current_client.event_from_exception(exception, options[:hint])
|
80
82
|
|
81
83
|
return unless event
|
82
84
|
|
83
|
-
options[:hint] ||= {}
|
84
|
-
options[:hint] = options[:hint].merge(exception: exception)
|
85
85
|
capture_event(event, **options, &block)
|
86
86
|
end
|
87
87
|
|
@@ -89,8 +89,8 @@ module Sentry
|
|
89
89
|
return unless current_client
|
90
90
|
|
91
91
|
options[:hint] ||= {}
|
92
|
-
options[:hint]
|
93
|
-
event = current_client.event_from_message(message)
|
92
|
+
options[:hint][:message] = message
|
93
|
+
event = current_client.event_from_message(message, options[:hint])
|
94
94
|
capture_event(event, **options, &block)
|
95
95
|
end
|
96
96
|
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Sentry
|
2
|
+
module Integrable
|
3
|
+
def register_integration(name:, version:)
|
4
|
+
Sentry.register_integration(name, version)
|
5
|
+
@integration_name = name
|
6
|
+
end
|
7
|
+
|
8
|
+
def integration_name
|
9
|
+
@integration_name
|
10
|
+
end
|
11
|
+
|
12
|
+
def capture_exception(exception, **options, &block)
|
13
|
+
options[:hint] ||= {}
|
14
|
+
options[:hint][:integration] = integration_name
|
15
|
+
Sentry.capture_exception(exception, **options, &block)
|
16
|
+
end
|
17
|
+
|
18
|
+
def capture_message(message, **options, &block)
|
19
|
+
options[:hint] ||= {}
|
20
|
+
options[:hint][:integration] = integration_name
|
21
|
+
Sentry.capture_message(message, **options, &block)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -16,7 +16,7 @@ module Sentry
|
|
16
16
|
scope.set_transaction_name(env["PATH_INFO"]) if env["PATH_INFO"]
|
17
17
|
scope.set_rack_env(env)
|
18
18
|
|
19
|
-
span = Sentry.start_transaction(name: scope.transaction_name, op:
|
19
|
+
span = Sentry.start_transaction(name: scope.transaction_name, op: transaction_op)
|
20
20
|
scope.set_span(span)
|
21
21
|
|
22
22
|
begin
|
@@ -25,13 +25,13 @@ module Sentry
|
|
25
25
|
finish_span(span, 500)
|
26
26
|
raise # Don't capture Sentry errors
|
27
27
|
rescue Exception => e
|
28
|
-
|
28
|
+
capture_exception(e)
|
29
29
|
finish_span(span, 500)
|
30
30
|
raise
|
31
31
|
end
|
32
32
|
|
33
33
|
exception = collect_exception(env)
|
34
|
-
|
34
|
+
capture_exception(exception) if exception
|
35
35
|
|
36
36
|
finish_span(span, response[0])
|
37
37
|
|
@@ -45,6 +45,14 @@ module Sentry
|
|
45
45
|
env['rack.exception'] || env['sinatra.error']
|
46
46
|
end
|
47
47
|
|
48
|
+
def transaction_op
|
49
|
+
"rack.request".freeze
|
50
|
+
end
|
51
|
+
|
52
|
+
def capture_exception(exception)
|
53
|
+
Sentry.capture_exception(exception)
|
54
|
+
end
|
55
|
+
|
48
56
|
def finish_span(span, status_code)
|
49
57
|
span.set_http_status(status_code)
|
50
58
|
span.finish
|
data/lib/sentry/span.rb
CHANGED
data/lib/sentry/transport.rb
CHANGED
@@ -67,8 +67,9 @@ module Sentry
|
|
67
67
|
# Convert to hash
|
68
68
|
event_hash = event.to_hash
|
69
69
|
|
70
|
-
event_id = event_hash[:event_id] || event_hash[
|
71
|
-
|
70
|
+
event_id = event_hash[:event_id] || event_hash["event_id"]
|
71
|
+
event_type = event_hash[:type] || event_hash["type"]
|
72
|
+
configuration.logger.info(LOGGER_PROGNAME) { "Sending #{event_type} #{event_id} to Sentry" }
|
72
73
|
encode(event_hash)
|
73
74
|
end
|
74
75
|
|
data/lib/sentry/version.rb
CHANGED
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: 4.1.
|
4
|
+
version: 4.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sentry Team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-12-
|
11
|
+
date: 2020-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -78,6 +78,7 @@ files:
|
|
78
78
|
- lib/sentry/dsn.rb
|
79
79
|
- lib/sentry/event.rb
|
80
80
|
- lib/sentry/hub.rb
|
81
|
+
- lib/sentry/integrable.rb
|
81
82
|
- lib/sentry/interface.rb
|
82
83
|
- lib/sentry/interfaces/exception.rb
|
83
84
|
- lib/sentry/interfaces/request.rb
|