use AddError everywhere (#2372)

This commit is contained in:
Patrick Hemmer
2017-04-24 14:13:26 -04:00
committed by Daniel Nelson
parent 06199523ac
commit 5ebe43f86f
95 changed files with 341 additions and 531 deletions

View File

@@ -11,7 +11,6 @@ import (
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/internal"
"github.com/influxdata/telegraf/internal/errchan"
"github.com/influxdata/telegraf/plugins/inputs"
)
@@ -72,14 +71,13 @@ func (k *Kubernetes) Description() string {
//Gather collects kubernetes metrics from a given URL
func (k *Kubernetes) Gather(acc telegraf.Accumulator) error {
var wg sync.WaitGroup
errChan := errchan.New(1)
wg.Add(1)
go func(k *Kubernetes) {
defer wg.Done()
errChan.C <- k.gatherSummary(k.URL, acc)
acc.AddError(k.gatherSummary(k.URL, acc))
}(k)
wg.Wait()
return errChan.Error()
return nil
}
func buildURL(endpoint string, base string) (*url.URL, error) {

View File

@@ -22,7 +22,7 @@ func TestKubernetesStats(t *testing.T) {
}
var acc testutil.Accumulator
err := k.Gather(&acc)
err := acc.GatherError(k.Gather)
require.NoError(t, err)
fields := map[string]interface{}{