sentry-ruby-core 4.9.0 → 5.0.1
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/lib/sentry/client.rb +4 -1
- data/lib/sentry/hub.rb +3 -0
- data/lib/sentry/transport/configuration.rb +1 -2
- data/lib/sentry/transport/http_transport.rb +53 -39
- data/lib/sentry/version.rb +1 -1
- data/lib/sentry-ruby.rb +1 -1
- data/sentry-ruby-core.gemspec +0 -1
- data/sentry-ruby.gemspec +0 -1
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 848bd1089194abb9be8a48b6c1c4c218dfba27a3555d8ae79a5ffe7d52a05569
|
4
|
+
data.tar.gz: c52711ba4c4275d35cc4ed54a0dc0936422a63e199de91c08e3e6964fb80d6d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb55681acc83a4c970fbf8dd7c6715fbef7b6d26ad0a4ca674bc463de13881887d33dd8673772e60e25c2c66b6cb1f111a6c23936b1683d74384296924bb2b33
|
7
|
+
data.tar.gz: 598c1571d00ca441b3a351dfe12c56967d3dae8e4f05b4a8f21b3e8fe16d0c94558e8dec5d211ff72aced12d5b433fb0f7f5f1b6ed522206d15847087dafd959
|
data/lib/sentry/client.rb
CHANGED
@@ -76,8 +76,9 @@ module Sentry
|
|
76
76
|
# @param hint [Hash] the hint data that'll be passed to `before_send` callback and the scope's event processors.
|
77
77
|
# @return [Event, nil]
|
78
78
|
def event_from_exception(exception, hint = {})
|
79
|
+
return unless @configuration.sending_allowed? && @configuration.exception_class_allowed?(exception)
|
80
|
+
|
79
81
|
integration_meta = Sentry.integrations[hint[:integration]]
|
80
|
-
return unless @configuration.exception_class_allowed?(exception)
|
81
82
|
|
82
83
|
Event.new(configuration: configuration, integration_meta: integration_meta).tap do |event|
|
83
84
|
event.add_exception_interface(exception)
|
@@ -90,6 +91,8 @@ module Sentry
|
|
90
91
|
# @param hint [Hash] the hint data that'll be passed to `before_send` callback and the scope's event processors.
|
91
92
|
# @return [Event]
|
92
93
|
def event_from_message(message, hint = {}, backtrace: nil)
|
94
|
+
return unless @configuration.sending_allowed?
|
95
|
+
|
93
96
|
integration_meta = Sentry.integrations[hint[:integration]]
|
94
97
|
event = Event.new(configuration: configuration, integration_meta: integration_meta, message: message)
|
95
98
|
event.add_threads_interface(backtrace: backtrace || caller)
|
data/lib/sentry/hub.rb
CHANGED
@@ -114,6 +114,9 @@ module Sentry
|
|
114
114
|
options[:hint][:message] = message
|
115
115
|
backtrace = options.delete(:backtrace)
|
116
116
|
event = current_client.event_from_message(message, options[:hint], backtrace: backtrace)
|
117
|
+
|
118
|
+
return unless event
|
119
|
+
|
117
120
|
capture_event(event, **options, &block)
|
118
121
|
end
|
119
122
|
|
@@ -3,8 +3,7 @@
|
|
3
3
|
module Sentry
|
4
4
|
class Transport
|
5
5
|
class Configuration
|
6
|
-
attr_accessor :timeout, :open_timeout, :proxy, :ssl, :ssl_ca_file, :ssl_verification, :
|
7
|
-
:encoding
|
6
|
+
attr_accessor :timeout, :open_timeout, :proxy, :ssl, :ssl_ca_file, :ssl_verification, :encoding
|
8
7
|
attr_reader :transport_class
|
9
8
|
|
10
9
|
def initialize
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "net/http"
|
4
|
+
require "zlib"
|
5
5
|
|
6
6
|
module Sentry
|
7
7
|
class HTTPTransport < Transport
|
@@ -12,14 +12,13 @@ module Sentry
|
|
12
12
|
DEFAULT_DELAY = 60
|
13
13
|
RETRY_AFTER_HEADER = "retry-after"
|
14
14
|
RATE_LIMIT_HEADER = "x-sentry-rate-limits"
|
15
|
-
|
16
|
-
attr_reader :conn, :adapter
|
15
|
+
USER_AGENT = "sentry-ruby/#{Sentry::VERSION}"
|
17
16
|
|
18
17
|
def initialize(*args)
|
19
18
|
super
|
20
|
-
@adapter = @transport_configuration.http_adapter || Faraday.default_adapter
|
21
|
-
@conn = set_conn
|
22
19
|
@endpoint = @dsn.envelope_endpoint
|
20
|
+
|
21
|
+
log_debug("Sentry HTTP Transport will connect to #{@dsn.server}")
|
23
22
|
end
|
24
23
|
|
25
24
|
def send_data(data)
|
@@ -30,29 +29,37 @@ module Sentry
|
|
30
29
|
encoding = GZIP_ENCODING
|
31
30
|
end
|
32
31
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
32
|
+
headers = {
|
33
|
+
'Content-Type' => CONTENT_TYPE,
|
34
|
+
'Content-Encoding' => encoding,
|
35
|
+
'X-Sentry-Auth' => generate_auth_header,
|
36
|
+
'User-Agent' => USER_AGENT
|
37
|
+
}
|
38
|
+
|
39
|
+
response = conn.start do |http|
|
40
|
+
request = ::Net::HTTP::Post.new(@endpoint, headers)
|
41
|
+
request.body = data
|
42
|
+
http.request(request)
|
38
43
|
end
|
39
44
|
|
40
|
-
if
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
+
if response.code.match?(/\A2\d{2}/)
|
46
|
+
if has_rate_limited_header?(response)
|
47
|
+
handle_rate_limited_response(response)
|
48
|
+
end
|
49
|
+
else
|
50
|
+
error_info = "the server responded with status #{response.code}"
|
45
51
|
|
46
|
-
|
47
|
-
|
48
|
-
handle_rate_limited_response(e.response[:headers])
|
52
|
+
if response.code == "429"
|
53
|
+
handle_rate_limited_response(response)
|
49
54
|
else
|
50
|
-
error_info += "\nbody: #{
|
51
|
-
error_info += " Error in headers is: #{
|
55
|
+
error_info += "\nbody: #{response.body}"
|
56
|
+
error_info += " Error in headers is: #{response['x-sentry-error']}" if response['x-sentry-error']
|
52
57
|
end
|
53
|
-
end
|
54
58
|
|
55
|
-
|
59
|
+
raise Sentry::ExternalError, error_info
|
60
|
+
end
|
61
|
+
rescue SocketError => e
|
62
|
+
raise Sentry::ExternalError.new(e.message)
|
56
63
|
end
|
57
64
|
|
58
65
|
private
|
@@ -119,32 +126,39 @@ module Sentry
|
|
119
126
|
@transport_configuration.encoding == GZIP_ENCODING && data.bytesize >= GZIP_THRESHOLD
|
120
127
|
end
|
121
128
|
|
122
|
-
def
|
123
|
-
server = @dsn.server
|
129
|
+
def conn
|
130
|
+
server = URI(@dsn.server)
|
124
131
|
|
125
|
-
|
132
|
+
use_ssl = server.scheme == "https"
|
133
|
+
port = use_ssl ? 443 : 80
|
126
134
|
|
127
|
-
|
128
|
-
@transport_configuration.
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
end
|
134
|
-
end
|
135
|
+
connection =
|
136
|
+
if proxy = @transport_configuration.proxy
|
137
|
+
::Net::HTTP.new(server.hostname, port, proxy[:uri].hostname, proxy[:uri].port, proxy[:user], proxy[:password])
|
138
|
+
else
|
139
|
+
::Net::HTTP.new(server.hostname, port, nil)
|
140
|
+
end
|
135
141
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
142
|
+
connection.use_ssl = use_ssl
|
143
|
+
connection.read_timeout = @transport_configuration.timeout
|
144
|
+
connection.write_timeout = @transport_configuration.timeout if connection.respond_to?(:write_timeout)
|
145
|
+
connection.open_timeout = @transport_configuration.open_timeout
|
146
|
+
|
147
|
+
ssl_configuration.each do |key, value|
|
148
|
+
connection.send("#{key}=", value)
|
140
149
|
end
|
150
|
+
|
151
|
+
connection
|
141
152
|
end
|
142
153
|
|
143
154
|
def ssl_configuration
|
144
|
-
{
|
155
|
+
configuration = {
|
145
156
|
verify: @transport_configuration.ssl_verification,
|
146
157
|
ca_file: @transport_configuration.ssl_ca_file
|
147
158
|
}.merge(@transport_configuration.ssl || {})
|
159
|
+
|
160
|
+
configuration[:verify_mode] = configuration.delete(:verify) ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE
|
161
|
+
configuration
|
148
162
|
end
|
149
163
|
end
|
150
164
|
end
|
data/lib/sentry/version.rb
CHANGED
data/lib/sentry-ruby.rb
CHANGED
data/sentry-ruby-core.gemspec
CHANGED
data/sentry-ruby.gemspec
CHANGED
@@ -18,6 +18,5 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/master/CHANGELOG.md"
|
19
19
|
|
20
20
|
spec.add_dependency "sentry-ruby-core", Sentry::VERSION
|
21
|
-
spec.add_dependency "faraday", "~> 1.0"
|
22
21
|
spec.add_dependency "concurrent-ruby", '~> 1.0', '>= 1.0.2'
|
23
22
|
end
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sentry-ruby-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.1
|
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-01-
|
11
|
+
date: 2022-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: faraday
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: concurrent-ruby
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|