Class: Buildkite::TestCollector::Uploader
- Inherits:
-
Object
- Object
- Buildkite::TestCollector::Uploader
- Defined in:
- lib/buildkite/test_collector/uploader.rb
Constant Summary collapse
- MAX_UPLOAD_ATTEMPTS =
3
- REQUEST_EXCEPTIONS =
[ URI::InvalidURIError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ReadTimeout, Net::OpenTimeout, OpenSSL::SSL::SSLError, OpenSSL::SSL::SSLErrorWaitReadable, EOFError ]
- RETRYABLE_UPLOAD_ERRORS =
[ Net::ReadTimeout, Net::OpenTimeout, OpenSSL::SSL::SSLError, OpenSSL::SSL::SSLErrorWaitReadable, EOFError, Errno::ETIMEDOUT, # TODO: some retries for server-side error would be great. ]
Class Method Summary collapse
Class Method Details
.tracer ⇒ Object
32 33 34 |
# File 'lib/buildkite/test_collector/uploader.rb', line 32 def self.tracer Thread.current[:_buildkite_tracer] end |
.traces ⇒ Object
7 8 9 |
# File 'lib/buildkite/test_collector/uploader.rb', line 7 def self.traces @traces ||= {} end |
.upload(data) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/buildkite/test_collector/uploader.rb', line 36 def self.upload(data) return false unless Buildkite::TestCollector.api_token http = Buildkite::TestCollector::HTTPClient.new(Buildkite::TestCollector.url) Thread.new do begin upload_attempts ||= 0 http.post_json(data) rescue *Buildkite::TestCollector::Uploader::RETRYABLE_UPLOAD_ERRORS => e if (upload_attempts += 1) < MAX_UPLOAD_ATTEMPTS retry end rescue StandardError => e $stderr.puts e $stderr.puts "#{Buildkite::TestCollector::NAME} #{Buildkite::TestCollector::VERSION} experienced an error when sending your data, you may be missing some executions for this run." end end end |