From b58cd78c79f3326bd6be9b76a286f4a5ac8a5fcd Mon Sep 17 00:00:00 2001 From: Cameron Sparr Date: Mon, 18 Jul 2016 17:26:44 +0100 Subject: [PATCH] Use errchan in redis input plugin this may address, or at least log issue #1462 --- plugins/inputs/redis/redis.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/plugins/inputs/redis/redis.go b/plugins/inputs/redis/redis.go index fc50387df..649786c2c 100644 --- a/plugins/inputs/redis/redis.go +++ b/plugins/inputs/redis/redis.go @@ -12,6 +12,7 @@ import ( "time" "github.com/influxdata/telegraf" + "github.com/influxdata/telegraf/internal/errchan" "github.com/influxdata/telegraf/plugins/inputs" ) @@ -96,9 +97,7 @@ func (r *Redis) Gather(acc telegraf.Accumulator) error { } var wg sync.WaitGroup - - var outerr error - + errChan := errchan.New(len(r.Servers)) for _, serv := range r.Servers { if !strings.HasPrefix(serv, "tcp://") || !strings.HasPrefix(serv, "unix://") { serv = "tcp://" + serv @@ -123,13 +122,12 @@ func (r *Redis) Gather(acc telegraf.Accumulator) error { wg.Add(1) go func(serv string) { defer wg.Done() - outerr = r.gatherServer(u, acc) + errChan.C <- r.gatherServer(u, acc) }(serv) } wg.Wait() - - return outerr + return errChan.Error() } func (r *Redis) gatherServer(addr *url.URL, acc telegraf.Accumulator) error {