Skip to content

Commit

Permalink
Adjust Influxdb buffering
Browse files Browse the repository at this point in the history
as we have experienced silent package drops. This issue is not fixed, it is just made less probable.
  • Loading branch information
mpass99 committed Dec 2, 2023
1 parent adfdf24 commit 2ba4fe7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pkg/monitoring/influxdb2_middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,21 @@ func InitializeInfluxDB(db *config.InfluxDB) (cancel func()) {
return func() {}
}

// How often to retry to write data.
const maxRetries = 50

Check warning on line 61 in pkg/monitoring/influxdb2_middleware.go

View check run for this annotation

Codecov / codecov/patch

pkg/monitoring/influxdb2_middleware.go#L61

Added line #L61 was not covered by tests
// How long to wait before retrying to write data.
const retryInterval = 30 * time.Second
const retryInterval = 5 * time.Second

Check warning on line 63 in pkg/monitoring/influxdb2_middleware.go

View check run for this annotation

Codecov / codecov/patch

pkg/monitoring/influxdb2_middleware.go#L63

Added line #L63 was not covered by tests
// How old the data can be before we stop retrying to write it. Should be larger than maxRetries * retryInterval.
const retryExpire = 10 * time.Minute
// How often to retry to write data.
const maxRetries = 10
// How many batches are buffered before dropping the oldest.
const retryBufferLimit = 100_000

Check warning on line 67 in pkg/monitoring/influxdb2_middleware.go

View check run for this annotation

Codecov / codecov/patch

pkg/monitoring/influxdb2_middleware.go#L66-L67

Added lines #L66 - L67 were not covered by tests

// Set options for retrying with the influx client.
options := influxdb2.DefaultOptions()
options.SetRetryInterval(uint(retryInterval.Milliseconds()))
options.SetMaxRetries(maxRetries)
options.SetMaxRetryTime(uint(retryExpire.Milliseconds()))
options.SetRetryBufferLimit(retryBufferLimit)

Check warning on line 74 in pkg/monitoring/influxdb2_middleware.go

View check run for this annotation

Codecov / codecov/patch

pkg/monitoring/influxdb2_middleware.go#L74

Added line #L74 was not covered by tests

// Create a new influx client.
client := influxdb2.NewClientWithOptions(db.URL, db.Token, options)
Expand Down

0 comments on commit 2ba4fe7

Please sign in to comment.