Skip to content

Commit

Permalink
handle client timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
RoeiDimiMSFT committed Dec 10, 2024
2 parents ae383bf + 6c2d0bf commit 83bffcf
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def send_message_to_loganalytics(call_payload, amount_of_documents)
elsif ewr.class == Excon::Error::RequestTimeout
force_retry = true
elsif ewr.class == Excon::Error::TooManyRequests
# thrutteling detected, backoff before resending
# throttling detected, backoff before resending
parsed_retry_after = response.data[:headers].include?('Retry-After') ? response.data[:headers]['Retry-After'].to_i : 0
seconds_to_sleep = parsed_retry_after > 0 ? parsed_retry_after : 30

Expand All @@ -82,6 +82,9 @@ def send_message_to_loganalytics(call_payload, amount_of_documents)
rescue Excon::Error::Socket => ex
@logger.trace("Exception: '#{ex.class.name}]#{ex} in posting data to #{api_name}. [amount_of_documents=#{amount_of_documents}]'")
force_retry = true
rescue Excon::Error::Timeout => ex
@logger.trace("Exception: '#{ex.class.name}]#{ex} in posting data to #{api_name}. [amount_of_documents=#{amount_of_documents}]'")
force_retry = true
rescue Exception => ex
@logger.trace("Exception in posting data to #{api_name}.[amount_of_documents=#{amount_of_documents} request payload=#{call_payload}]")
@logger.error("Exception in posting data to #{api_name}. [Exception: '[#{ex.class.name}]#{ex}, amount of documents=#{amount_of_documents}]'")
Expand Down

0 comments on commit 83bffcf

Please sign in to comment.