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
|