sentry-ruby-core 4.9.1 → 5.0.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: 581302d8f4b4352dad44e05ccf4bbd052b2444940cde2712dbeb7ba79db8dd6d
4
- data.tar.gz: ede4e7f3a4d8c156f19c336fbd52862b84c1ef60e42bdf8e55d491f3634da7c7
3
+ metadata.gz: 2f6a137330d349e7d0cfa5535bdf80f940266df9e01b4f134df6a49c475724fa
4
+ data.tar.gz: 27d2fd1c95d69dc1cf6b01a2ca6c9c6e58fcaf2cba2a76706b6a26fe323f4599
5
5
  SHA512:
6
- metadata.gz: '02219e1309e5d539c5229ff74aac3e0377cd1480a20b99d6cc9a690e9d16967a742e0f2f5d599ec30e0ee303109b5975b342ea9645f90c4bc24111ee4beec777'
7
- data.tar.gz: 76a5a05b324edb0571d1fe61104554444db6210f0ce76b9028e8665fcf2f083fbfa967bb941997006017931d84fdab7d3e45ee1c038d25939f1cd4a8c57ff2e8
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, :http_adapter, :faraday_builder,
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 'faraday'
4
- require 'zlib'
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
- response = conn.post @endpoint do |req|
34
- req.headers['Content-Type'] = CONTENT_TYPE
35
- req.headers['Content-Encoding'] = encoding
36
- req.headers['X-Sentry-Auth'] = generate_auth_header
37
- req.body = data
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 has_rate_limited_header?(response.headers)
41
- handle_rate_limited_response(response.headers)
42
- end
43
- rescue Faraday::Error => e
44
- error_info = e.message
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
- if e.response
47
- if e.response[:status] == 429
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: #{e.response[:body]}"
51
- error_info += " Error in headers is: #{e.response[:headers]['x-sentry-error']}" if e.response[:headers]['x-sentry-error']
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
- raise Sentry::ExternalError, error_info
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 set_conn
123
- server = @dsn.server
129
+ def conn
130
+ server = URI(@dsn.server)
124
131
 
125
- log_debug("Sentry HTTP Transport connecting to #{server}")
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
- Faraday.new(server, :ssl => ssl_configuration, :proxy => @transport_configuration.proxy) do |builder|
128
- @transport_configuration.faraday_builder&.call(builder)
129
- builder.response :raise_error
130
- builder.options.merge! faraday_opts
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
- # TODO: deprecate and replace where possible w/Faraday Builder
137
- def faraday_opts
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sentry
4
- VERSION = "4.9.1"
4
+ VERSION = "5.0.2"
5
5
  end
data/lib/sentry-ruby.rb CHANGED
@@ -174,7 +174,7 @@ module Sentry
174
174
  #
175
175
  # @return [Boolean]
176
176
  def initialized?
177
- !!@main_hub
177
+ !!get_main_hub
178
178
  end
179
179
 
180
180
  # Returns an uri for security policy reporting that's generated from the given DSN
@@ -22,6 +22,5 @@ Gem::Specification.new do |spec|
22
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
23
  spec.require_paths = ["lib"]
24
24
 
25
- spec.add_dependency "faraday"
26
25
  spec.add_dependency "concurrent-ruby"
27
26
  end
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.9.1
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-14 00:00:00.000000000 Z
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