Skip to content

Commit

Permalink
Fix unit tests and minor touchups
Browse files Browse the repository at this point in the history
  • Loading branch information
chusitoo committed Dec 30, 2024
1 parent 8008e8c commit 48402d9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion exporters/otlp/test/otlp_http_exporter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ TEST_P(OtlpHttpExporterRetryIntegrationTests, StatusCodes)
return response.code;
}};
HTTP_SERVER_NS::HttpServer server;
server.setKeepalive(false);
server.setKeepalive(true);
server.setServerName("test_server");
server.addHandler("/v1/traces", request_handler);
ASSERT_EQ(server.addListeningPort(4318), 4318);
Expand Down
2 changes: 1 addition & 1 deletion ext/src/http/client/curl/http_client_curl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ bool HttpClient::doRetrySessions()
retry_it != pending_to_retry_sessions_.crend();)
{
const auto session = *retry_it;
const auto operation = (nullptr != session) ? session->GetOperation().get() : nullptr;
const auto operation = session ? session->GetOperation().get() : nullptr;

if (!operation)
{
Expand Down
5 changes: 4 additions & 1 deletion ext/src/http/client/curl/http_operation_curl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,8 @@ bool HttpOperation::IsRetryable()
const auto is_retryable = std::find(kRetryableStatusCodes.cbegin(), kRetryableStatusCodes.cend(),
response_code_) != kRetryableStatusCodes.cend();

return is_retryable && retry_attempts_ < retry_policy_.max_attempts;
return is_retryable && (last_curl_result_ == CURLE_OK) &&
(retry_attempts_ < retry_policy_.max_attempts);
}

std::chrono::system_clock::time_point HttpOperation::NextRetryTime()
Expand Down Expand Up @@ -1404,6 +1405,8 @@ void HttpOperation::PerformCurlMessage(CURLcode code)
ReleaseResponse();
// Rewind request data so that read callback can re-transfer the payload
request_nwrite_ = 0;
// Reset session state
DispatchEvent(opentelemetry::ext::http::client::SessionState::Connecting);
}
else
{
Expand Down

0 comments on commit 48402d9

Please sign in to comment.