From 7b01be9fc6cc6fd80701e232f8e269da059d0457 Mon Sep 17 00:00:00 2001 From: Cody Lee Date: Sun, 11 Dec 2022 14:37:53 -0600 Subject: [PATCH] flush influx errors --- pkg/influxunifi/influxdb.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/influxunifi/influxdb.go b/pkg/influxunifi/influxdb.go index 3b8c8c9a..ed7a332f 100644 --- a/pkg/influxunifi/influxdb.go +++ b/pkg/influxunifi/influxdb.go @@ -260,12 +260,14 @@ func (u *InfluxUnifi) ReportMetrics(m *poller.Metrics, e *poller.Events) (*Repor r.writer = u.influxV2.WriteAPI(u.Org, u.Bucket) go u.collect(r, r.ch) + go u.drainErrors(r) // Batch all the points. u.loopPoints(r) r.wg.Wait() // wait for all points to finish batching! // Flush all the points. r.writer.Flush() + go u.drainErrors(r) } else { var err error @@ -292,6 +294,12 @@ func (u *InfluxUnifi) ReportMetrics(m *poller.Metrics, e *poller.Events) (*Repor return r, nil } +func (u *InfluxUnifi) drainErrors(r *Report) { + for e := range r.writer.Errors() { + u.LogErrorf("error encountered by influx flush: %v", e) + } +} + // collect runs in a go routine and batches all the points. func (u *InfluxUnifi) collect(r report, ch chan *metric) { for m := range ch {