Skip to content

Commit f5e17e2

Browse files
committed
[CHORE] Shorten the comments to what the code does not already say
The switch comment and the two test comments described what the code used to do before the fix. That reads as history beside code that no longer has it, and it belongs in this PR and in the commit message. What is left states the invariant: every state the client can end a request on is named here, and the exchange below decides ordering. Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
1 parent 88d49e9 commit f5e17e2

2 files changed

Lines changed: 7 additions & 12 deletions

File tree

‎exporters/otlp/src/otlp_http_client.cc‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,9 @@ class ResponseHandler : public http_client::EventHandler
187187
{
188188
// need to modify stopping_ under lock before calling callback
189189
//
190-
// Every state a request can end on, because a request that ends on one nobody answers leaves
191-
// the caller waiting for a callback that is not coming. Destroyed, ReadError and WriteError
192-
// are the three the client can finish on that used to be logged and then dropped. Ordering is
193-
// decided by the exchange below rather than here, so one of these arriving after a response
194-
// has already been reported does not report a second time.
190+
// Every state the client can end a request on. A state missing from here leaves the caller
191+
// waiting for a callback that never comes. The exchange below decides ordering, so a state
192+
// arriving after a response does not report a second time.
195193
bool need_stop = false;
196194
switch (state)
197195
{

‎exporters/otlp/test/otlp_http_exporter_custom_client_test.cc‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,8 @@ class OtlpHttpExporterCustomClientTestPeer : public ::testing::Test
9292
return {new OtlpHttpClient(MakeOtlpHttpClientOptions(), http_client), http_client};
9393
}
9494

95-
// The same, with the outcome recorded. A request that never settles calls this no times, and one
96-
// that settles twice calls it twice, so both failures the terminal states can produce are
97-
// visible in the count rather than only in a timeout.
95+
// Records the outcome. A request that never settles calls back no times and one that settles
96+
// twice calls back twice, so both failures show in the count rather than only in a timeout.
9897
static void ExportOneRequest(OtlpHttpClient &otlp_client,
9998
const std::shared_ptr<std::atomic<int>> &calls,
10099
const std::shared_ptr<sdk::common::ExportResult> &result)
@@ -262,10 +261,8 @@ TEST_F(OtlpHttpExporterCustomClientTestPeer, ForceFlushReportsSuccessOnceTheSess
262261
EXPECT_TRUE(otlp_client.ForceFlush(std::chrono::milliseconds{50}));
263262
}
264263

265-
// Every state the client can finish a request on has to end that request. These three used to be
266-
// logged and then dropped: the switch that decides whether the request is over did not name them,
267-
// so a client that ended a transfer this way left the caller waiting for a callback that was not
268-
// coming, and ForceFlush and Shutdown could only give up on their own deadlines.
264+
// A client that finishes a transfer on ReadError, WriteError or Destroyed ends the request: the
265+
// result callback runs once, and ForceFlush returns rather than waiting out its deadline.
269266
TEST_F(OtlpHttpExporterCustomClientTestPeer, ATerminalClientEventEndsTheRequest)
270267
{
271268
for (const auto state :

0 commit comments

Comments
 (0)