Skip to content

Commit

Permalink
Fixed issue with CloudWatchLogMetrics not updating counters when no e…
Browse files Browse the repository at this point in the history
…vent handles are present

Signed-off-by: Marcos Gonzalez Mayedo <[email protected]>
  • Loading branch information
Marcos Gonzalez Mayedo committed Aug 4, 2023
1 parent fbfb82e commit dec95b8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public void dispatchLogs(List<InputLogEvent> inputLogEvents, Collection<EventHan
.cloudWatchLogsMetrics(cloudWatchLogsMetrics)
.putLogEventsRequest(putLogEventsRequest)
.eventHandles(eventHandles)
.totalEventCount(inputLogEvents.size())
.backOffTimeBase(backOffTimeBase)
.retryCount(retryCount)
.build());
Expand All @@ -97,6 +98,7 @@ protected static class Uploader implements Runnable {
private final CloudWatchLogsMetrics cloudWatchLogsMetrics;
private final PutLogEventsRequest putLogEventsRequest;
private final Collection<EventHandle> eventHandles;
private final int totalEventCount;
private final int retryCount;
private final long backOffTimeBase;

Expand Down Expand Up @@ -132,10 +134,10 @@ public void upload() {


if (failedToTransmit) {
cloudWatchLogsMetrics.increaseLogEventFailCounter(eventHandles.size());
cloudWatchLogsMetrics.increaseLogEventFailCounter(totalEventCount);
releaseEventHandles(false, eventHandles);
} else {
cloudWatchLogsMetrics.increaseLogEventSuccessCounter(eventHandles.size());
cloudWatchLogsMetrics.increaseLogEventSuccessCounter(totalEventCount);
releaseEventHandles(true, eventHandles);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ CloudWatchLogsDispatcher.Uploader getUploader() {
.cloudWatchLogsMetrics(mockCloudWatchLogsMetrics)
.putLogEventsRequest(getMockPutLogEventsRequest())
.eventHandles(getTestEventHandles())
.totalEventCount(ThresholdConfig.DEFAULT_BATCH_SIZE)
.retryCount(ThresholdConfig.DEFAULT_RETRY_COUNT)
.backOffTimeBase(ThresholdConfig.DEFAULT_BACKOFF_TIME)
.build();
Expand Down

0 comments on commit dec95b8

Please sign in to comment.