vendor: github.com/fluent/fluent-logger-golang v1.9.0

Updates the fluent logger library to v1.9.0. The update includes the following commit:

* [Add periodic reconnection functionality](fluent/fluent-logger-golang@1c05506)

See https://github.com/fluent/fluent-logger-golang/compare/v1.8.0..v1.9.0

Signed-off-by: Conor Evans <coevans@tcd.ie>
This commit is contained in:
Conor Evans 2021-12-22 15:28:09 +01:00 committed by Sebastiaan van Stijn
parent 64441553e7
commit 3500d7e472
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
4 changed files with 28 additions and 2 deletions

View File

@ -103,7 +103,7 @@ github.com/godbus/dbus/v5 c88335c0b1d28a30e7fc76d526a0
github.com/Graylog2/go-gelf 1550ee647df0510058c9d67a45c56f18911d80b8 # v2 branch
# fluent-logger-golang deps
github.com/fluent/fluent-logger-golang 0b652e850a9140d0b1db6390d8925d0601e952db # v1.8.0
github.com/fluent/fluent-logger-golang 5538e904aeb515c10a624da620581bdf420d4b8a # v1.9.0
github.com/philhofer/fwd bb6d471dc95d4fe11e432687f8b70ff496cf3136 # v1.0.0
github.com/tinylib/msgp af6442a0fcf6e2a1b824f70dd0c734f01e817751 # v1.1.0

View File

@ -132,6 +132,11 @@ When Async is enabled, if this is callback is provided, it will be called on eve
takes two arguments - a `[]byte` of the message that was to be sent and an `error`. If the `error` is not nil this means the
delivery of the message was unsuccessful.
### AsyncReconnectInterval
When async is enabled, this option defines the interval (ms) at which the connection
to the fluentd-address is re-established. This option is useful if the address
may resolve to one or more IP addresses, e.g. a Consul service address.
### SubSecondPrecision
Enable time encoding as EventTime, which contains sub-second precision values. The messages encoded with this option can be received only by Fluentd v0.14 or later.

View File

@ -65,6 +65,11 @@ type Config struct {
AsyncConnect bool `json:"async_connect"`
MarshalAsJSON bool `json:"marshal_as_json"`
// AsyncReconnectInterval defines the interval (ms) at which the connection
// to the fluentd-address is re-established. This option is useful if the address
// may resolve to one or more IP addresses, e.g. a Consul service address.
AsyncReconnectInterval int `json:"async_reconnect_interval"`
// Sub-second precision timestamps are only possible for those using fluentd
// v0.14+ and serializing their messages with msgpack.
SubSecondPrecision bool `json:"sub_second_precision"`
@ -108,6 +113,9 @@ type Fluent struct {
closed bool
wg sync.WaitGroup
// time at which the most recent connection to fluentd-address was established.
latestReconnectTime time.Time
muconn sync.RWMutex
conn net.Conn
}
@ -447,6 +455,10 @@ func (f *Fluent) connect(ctx context.Context) (err error) {
err = NewErrUnknownNetwork(f.Config.FluentNetwork)
}
if err == nil {
f.latestReconnectTime = time.Now()
}
return err
}
@ -508,6 +520,15 @@ func (f *Fluent) run(ctx context.Context) {
return
}
if f.AsyncReconnectInterval > 0 {
if time.Since(f.latestReconnectTime) > time.Duration(f.AsyncReconnectInterval)*time.Millisecond {
f.muconn.Lock()
f.close()
f.connectWithRetry(ctx)
f.muconn.Unlock()
}
}
err := f.writeWithRetry(ctx, entry)
if err != nil && err != errIsClosing {
fmt.Fprintf(os.Stderr, "[%s] Unable to send logs to fluentd, reconnecting...\n", time.Now().Format(time.RFC3339))

View File

@ -1,3 +1,3 @@
package fluent
const Version = "1.4.0"
const Version = "1.9.0"