sentry-ruby-core 4.9.2 → 5.0.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 +1 -0
- data/lib/sentry/transport/configuration.rb +1 -2
- data/lib/sentry/transport/http_transport.rb +50 -39
- data/lib/sentry/version.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: 2f6a137330d349e7d0cfa5535bdf80f940266df9e01b4f134df6a49c475724fa
|
4
|
+
data.tar.gz: 27d2fd1c95d69dc1cf6b01a2ca6c9c6e58fcaf2cba2a76706b6a26fe323f4599
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6f8a78bd9bdb89ca6f710a036e1e4917891968e1de929da024dbebc12a5d86642a51e367b329b6a1c9f6c670af47d5bad0a8fd15804c3511f33edd5333ae789
|
7
|
+
data.tar.gz: '0559dd91dcdb831e132d5e74d0680cdedbb3e07c83b1f3129e635eb868bc8fb5a84e27813276058d436709543ec45f602f3f89ababec9295b1b0208292ee77c7'
|
data/lib/sentry/client.rb
CHANGED
@@ -108,6 +108,7 @@ module Sentry
|
|
108
108
|
event.contexts.merge!(trace: transaction.get_trace_context)
|
109
109
|
event.timestamp = transaction.timestamp
|
110
110
|
event.start_timestamp = transaction.start_timestamp
|
111
|
+
event.tags = transaction.tags
|
111
112
|
|
112
113
|
finished_spans = transaction.span_recorder.spans.select { |span| span.timestamp && span != transaction }
|
113
114
|
event.spans = finished_spans.map(&:to_hash)
|
@@ -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,36 @@ 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
|
+
connection =
|
133
|
+
if proxy = @transport_configuration.proxy
|
134
|
+
::Net::HTTP.new(server.hostname, server.port, proxy[:uri].hostname, proxy[:uri].port, proxy[:user], proxy[:password])
|
135
|
+
else
|
136
|
+
::Net::HTTP.new(server.hostname, server.port, nil)
|
137
|
+
end
|
126
138
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
builder.headers[:user_agent] = "sentry-ruby/#{Sentry::VERSION}"
|
132
|
-
builder.adapter(*adapter)
|
133
|
-
end
|
134
|
-
end
|
139
|
+
connection.use_ssl = server.scheme == "https"
|
140
|
+
connection.read_timeout = @transport_configuration.timeout
|
141
|
+
connection.write_timeout = @transport_configuration.timeout if connection.respond_to?(:write_timeout)
|
142
|
+
connection.open_timeout = @transport_configuration.open_timeout
|
135
143
|
|
136
|
-
|
137
|
-
|
138
|
-
[:timeout, :open_timeout].each_with_object({}) do |opt, memo|
|
139
|
-
memo[opt] = @transport_configuration.public_send(opt) if @transport_configuration.public_send(opt)
|
144
|
+
ssl_configuration.each do |key, value|
|
145
|
+
connection.send("#{key}=", value)
|
140
146
|
end
|
147
|
+
|
148
|
+
connection
|
141
149
|
end
|
142
150
|
|
143
151
|
def ssl_configuration
|
144
|
-
{
|
152
|
+
configuration = {
|
145
153
|
verify: @transport_configuration.ssl_verification,
|
146
154
|
ca_file: @transport_configuration.ssl_ca_file
|
147
155
|
}.merge(@transport_configuration.ssl || {})
|
156
|
+
|
157
|
+
configuration[:verify_mode] = configuration.delete(:verify) ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE
|
158
|
+
configuration
|
148
159
|
end
|
149
160
|
end
|
150
161
|
end
|
data/lib/sentry/version.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.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: 2022-01-
|
11
|
+
date: 2022-01-31 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
|