Skip to content

Commit

Permalink
opentelemetry: add the option to discard buffer response body for htt…
Browse files Browse the repository at this point in the history
…p async exporter (envoyproxy#35572)

only the response code is used for logging purpose.

Risk Level: low
Testing: unit test

Signed-off-by: Boteng Yao <[email protected]>
  • Loading branch information
botengyao authored Aug 7, 2024
1 parent d78e813 commit 84e1ed2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,11 @@ bool OpenTelemetryHttpTraceExporter::log(const ExportTraceServiceRequest& reques
}
message->body().add(request_body);

const auto options = Http::AsyncClient::RequestOptions().setTimeout(std::chrono::milliseconds(
DurationUtil::durationToMilliseconds(http_service_.http_uri().timeout())));
const auto options =
Http::AsyncClient::RequestOptions()
.setTimeout(std::chrono::milliseconds(
DurationUtil::durationToMilliseconds(http_service_.http_uri().timeout())))
.setDiscardResponseBody(true);

Http::AsyncClient::Request* in_flight_request =
thread_local_cluster->httpAsyncClient().send(std::move(message), *this, options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,11 @@ TEST_F(OpenTelemetryHttpTraceExporterTest, CreateExporterAndExportSpan) {
Http::MockAsyncClientRequest request(&cluster_manager_.thread_local_cluster_.async_client_);
Http::AsyncClient::Callbacks* callback;

EXPECT_CALL(
cluster_manager_.thread_local_cluster_.async_client_,
send_(_, _, Http::AsyncClient::RequestOptions().setTimeout(std::chrono::milliseconds(250))))
EXPECT_CALL(cluster_manager_.thread_local_cluster_.async_client_,
send_(_, _,
Http::AsyncClient::RequestOptions()
.setTimeout(std::chrono::milliseconds(250))
.setDiscardResponseBody(true)))
.WillOnce(
Invoke([&](Http::RequestMessagePtr& message, Http::AsyncClient::Callbacks& callbacks,
const Http::AsyncClient::RequestOptions&) -> Http::AsyncClient::Request* {
Expand Down

0 comments on commit 84e1ed2

Please sign in to comment.