Module: ApolloStudioTracing::API

Extended by:
API
Included in:
API
Defined in:
lib/apollo-studio-tracing/api.rb

Constant Summary collapse

APOLLO_URL =
'https://engine-report.apollodata.com/api/ingress/traces'
APOLLO_URI =
::URI.parse(APOLLO_URL)
UploadAttemptError =
Class.new(StandardError)
RetryableUploadAttemptError =
Class.new(UploadAttemptError)

Instance Method Summary collapse

Instance Method Details

#upload(report_data, max_attempts:, min_retry_delay_secs:, **options) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/apollo-studio-tracing/api.rb', line 17

def upload(report_data, max_attempts:, min_retry_delay_secs:, **options)
  attempt ||= 0
  attempt_upload(report_data, **options)
rescue UploadAttemptError => e
  attempt += 1
  if e.is_a?(RetryableUploadAttemptError) && attempt < max_attempts
    retry_delay = min_retry_delay_secs * 2**attempt
    ApolloStudioTracing.logger.warn(
      "Attempt to send trace report failed and will be retried in #{retry_delay} " \
      "secs: #{e.message}",
    )
    sleep(retry_delay)
    retry
  else
    ApolloStudioTracing.logger.warn("Failed to send trace report: #{e.message}")
  end
end