Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,13 @@ public void testBatchSizeFromConfig() throws Exception {
MDC.put("requestId", "testErrorLog");
MDC.put("requestTime", 199 + "");
this.logger.info(batchRunId + " Custom batch size Final Batch Groot ");
Thread.sleep(4000);
assertEquals(1, this.appender.apiCalls);

// The 200th line sends the batch on another thread. Wait for that flush instead of a fixed time: a request to
// the real endpoint now and then takes several seconds, or fails and is retried by the appender
this.appender.awaitFlushCompletion();

isOk();
assertEquals(1, this.appender.acceptedCalls);
}

private void isOk() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ public class LogtailAppenderDecorator extends LogtailAppender {
private Exception exception;
private LogtailResponse response;
protected int apiCalls = 0;
// Calls answered with 202, i.e. apiCalls without the failed ones the appender retried
protected int acceptedCalls = 0;

@Override
protected LogtailResponse callHttpURLConnection(int flushedSize) throws IOException {
try {
apiCalls++;
this.response = super.callHttpURLConnection(flushedSize);
if (isOK()) {
acceptedCalls++;
}

return this.response;
} catch (Exception e) {
Expand Down
Loading