mirror of
https://github.com/unpoller/unpoller.git
synced 2026-03-31 06:24:19 -04:00
flush influx errors
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user