Fix err race condition and partial failure issues

closes #1439
closes #1440
closes #1441
closes #1442
closes #1443
closes #1444
closes #1445
This commit is contained in:
Cameron Sparr
2016-07-19 14:03:28 +01:00
parent cbf5a55c7d
commit 82166a36d0
9 changed files with 53 additions and 52 deletions

View File

@@ -12,6 +12,7 @@ import (
"time"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/internal/errchan"
"github.com/influxdata/telegraf/plugins/inputs"
)
@@ -34,7 +35,7 @@ func (n *Nginx) Description() string {
func (n *Nginx) Gather(acc telegraf.Accumulator) error {
var wg sync.WaitGroup
var outerr error
errChan := errchan.New(len(n.Urls))
for _, u := range n.Urls {
addr, err := url.Parse(u)
@@ -45,13 +46,12 @@ func (n *Nginx) Gather(acc telegraf.Accumulator) error {
wg.Add(1)
go func(addr *url.URL) {
defer wg.Done()
outerr = n.gatherUrl(addr, acc)
errChan.C <- n.gatherUrl(addr, acc)
}(addr)
}
wg.Wait()
return outerr
return errChan.Error()
}
var tr = &http.Transport{