Skip to content

Commit 623da54

Browse files
committed
refactor and fix curl metrics
1 parent 93cf97a commit 623da54

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

src/aws-cpp-sdk-core/source/http/curl/CurlHttpClient.cpp

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -887,41 +887,37 @@ std::shared_ptr<HttpResponse> CurlHttpClient::MakeRequest(const std::shared_ptr<
887887
}
888888

889889
#if LIBCURL_VERSION_NUM >= 0x073700 // 7.55.0
890-
curl_off_t AppConnectT;
891-
ret = curl_easy_getinfo(connectionHandle, CURLINFO_APPCONNECT_TIME_T, &AppConnectT); // Ssl Latency
892-
if (ret == CURLE_OK)
893-
{
894-
request->AddRequestMetric(GetHttpClientMetricNameByType(HttpClientMetricsType::SslLatency), AppConnectT * 1000);
895-
}
890+
curl_off_t metric;
891+
ret = curl_easy_getinfo(connectionHandle, CURLINFO_APPCONNECT_TIME_T, &metric); // Ssl Latency
896892
#else
897-
ret = curl_easy_getinfo(connectionHandle, CURLINFO_APPCONNECT_TIME, &timep); // Ssl Latency
893+
double metric;
894+
ret = curl_easy_getinfo(connectionHandle, CURLINFO_APPCONNECT_TIME, &metric); // Ssl Latency
895+
#endif
898896
if (ret == CURLE_OK)
899897
{
900-
request->AddRequestMetric(GetHttpClientMetricNameByType(HttpClientMetricsType::SslLatency), static_cast<int64_t>(timep * 1000));
898+
request->AddRequestMetric(GetHttpClientMetricNameByType(HttpClientMetricsType::SslLatency), static_cast<int64_t>(metric * 1000));
901899
}
902-
#endif
903900

904-
curl_off_t speed;
905901
#if LIBCURL_VERSION_NUM >= 0x073700 // 7.55.0
906-
ret = curl_easy_getinfo(connectionHandle, CURLINFO_SPEED_DOWNLOAD_T, &speed); // throughput
902+
ret = curl_easy_getinfo(connectionHandle, CURLINFO_SPEED_DOWNLOAD_T, &metric); // throughput
907903
#else
908-
ret = curl_easy_getinfo(connectionHandle, CURLINFO_SPEED_DOWNLOAD, &speed); // throughput
904+
ret = curl_easy_getinfo(connectionHandle, CURLINFO_SPEED_DOWNLOAD, &metric); // throughput
909905
#endif
910906
if (ret == CURLE_OK)
911907
{
912908
//Record two metric names to preserve backwards compat
913-
request->AddRequestMetric(GetHttpClientMetricNameByType(HttpClientMetricsType::Throughput), static_cast<int64_t>(speed));
914-
request->AddRequestMetric(GetHttpClientMetricNameByType(HttpClientMetricsType::DownloadSpeed), static_cast<int64_t>(speed));
909+
request->AddRequestMetric(GetHttpClientMetricNameByType(HttpClientMetricsType::Throughput), static_cast<int64_t>(metric));
910+
request->AddRequestMetric(GetHttpClientMetricNameByType(HttpClientMetricsType::DownloadSpeed), static_cast<int64_t>(metric));
915911
}
916912

917913
#if LIBCURL_VERSION_NUM >= 0x073700 // 7.55.0
918-
ret = curl_easy_getinfo(connectionHandle, CURLINFO_SPEED_UPLOAD_T, &speed); // Upload Speed
914+
ret = curl_easy_getinfo(connectionHandle, CURLINFO_SPEED_UPLOAD_T, &metric); // Upload Speed
919915
#else
920-
ret = curl_easy_getinfo(connectionHandle, CURLINFO_SPEED_UPLOAD, &speed); // Upload Speed
916+
ret = curl_easy_getinfo(connectionHandle, CURLINFO_SPEED_UPLOAD, &metric); // Upload Speed
921917
#endif
922918
if (ret == CURLE_OK)
923919
{
924-
request->AddRequestMetric(GetHttpClientMetricNameByType(HttpClientMetricsType::UploadSpeed), static_cast<int64_t>(speed));
920+
request->AddRequestMetric(GetHttpClientMetricNameByType(HttpClientMetricsType::UploadSpeed), static_cast<int64_t>(metric));
925921
}
926922

927923
const char* ip = nullptr;

0 commit comments

Comments
 (0)