Skip to content

Commit

Permalink
Speed up shutdown and tidy up readme
Browse files Browse the repository at this point in the history
  • Loading branch information
mec07 committed Aug 15, 2020
1 parent 48e82d5 commit e19201c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.2.2] - 2020-08-14

### Changed

- Decrease the shutdown time -- the final batch after `CloudWatchWriter.Close()` has been called will be sent as soon as it has been formed, rather than waiting for the next scheduled batch time.

## [0.2.1] - 2020-08-14

### Changed
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ To change the batch frequency, you can set the time interval between batches to
err := cloudWatchWriter.SetBatchInterval(time.Second)
```
If you set it below 200 milliseconds it will return an error.
This interval is not guaranteed as a long running request to CloudWatch could delay to the next batch.
This is because CloudWatch expects to receive logs in sequence and not in parallel, so this has been written to send them in sequence.

The batch interval is not guaranteed as two things can alter how often the batches get delivered:
- as soon as 1MB of logs or 10k logs have accumulated, they are sent (due to AWS restrictions on batch size);
- we have to send the batches in sequence (an AWS restriction) so a long running request to CloudWatch can delay the next batch.

## Acknowledgements
Much thanks has to go to the creator of `zerolog` (https://github.com/rs/zerolog), for creating such a good logger.
Expand Down
5 changes: 3 additions & 2 deletions cloudwatch_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,9 @@ func (c *CloudWatchWriter) queueMonitor() {
item := c.queue.Dequeue()
if item == nil {
// Empty queue, means no logs to process
if c.isClosing() && batch == nil {
// at this point we've processed all the logs and can safely
if c.isClosing() {
c.sendBatch(batch)
// At this point we've processed all the logs and can safely
// close.
close(c.done)
return
Expand Down

0 comments on commit e19201c

Please sign in to comment.