From 43a9b37eabfe45a28bcf2a054a3d0aaaf0cab4ea Mon Sep 17 00:00:00 2001 From: Lukasz Jagiello Date: Fri, 9 Sep 2016 09:45:00 +0000 Subject: [PATCH] Accumulator.AddError() interface instead of returning err --- plugins/inputs/solr/solr.go | 12 ++++++------ plugins/inputs/solr/solr_test.go | 3 +-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/plugins/inputs/solr/solr.go b/plugins/inputs/solr/solr.go index 1794ea0c8..4eed938b2 100644 --- a/plugins/inputs/solr/solr.go +++ b/plugins/inputs/solr/solr.go @@ -374,28 +374,28 @@ func (s *Solr) gatherCoreStats(url string, core string, acc telegraf.Accumulator for _, category := range []string{"CORE", "QUERYHANDLER", "UPDATEHANDLER", "CACHE"} { metrics := &Metrics{} if err := s.gatherData(fmt.Sprintf("%s&cat=%s", url, category), metrics); err != nil { - return err + acc.AddError(fmt.Errorf("JSON fetch error: %s", err)) } switch category { case "CORE": if err := gatherCoreMetrics(metrics.SolrMbeans[1], core, category, acc); err != nil { - return err + acc.AddError(fmt.Errorf("core category: %s", err)) } case "QUERYHANDLER": if err := gatherQueryHandlerMetrics(metrics.SolrMbeans[1], core, category, acc); err != nil { - return err + acc.AddError(fmt.Errorf("query handler category: %s", err)) } case "UPDATEHANDLER": if err := gatherUpdateHandlerMetrics(metrics.SolrMbeans[1], core, category, acc); err != nil { - return err + acc.AddError(fmt.Errorf("update handler category: %s", err)) } case "CACHE": if err := gatherCacheMetrics(metrics.SolrMbeans[1], core, category, acc); err != nil { - return err + acc.AddError(fmt.Errorf("cache category: %s", err)) } default: err := errors.New("unrecognized category") - return err + acc.AddError(fmt.Errorf("category: %s", err)) } } return nil diff --git a/plugins/inputs/solr/solr_test.go b/plugins/inputs/solr/solr_test.go index 24b8bd419..6c26be02a 100644 --- a/plugins/inputs/solr/solr_test.go +++ b/plugins/inputs/solr/solr_test.go @@ -8,7 +8,6 @@ import ( "testing" "github.com/influxdata/telegraf/testutil" - "github.com/stretchr/testify/require" ) @@ -43,7 +42,7 @@ func TestSetDefaults(t *testing.T) { solr.Servers = []string{"http://example.com:8983"} solr.client.Transport = newTransportMock(http.StatusOK, adminCoresResponse) - cores, max, err := solr.setDefaults() + _, max, err := solr.setDefaults() if max != 5 { err = fmt.Errorf("Received unexpected error: max number of cores: %v, expected 5", max) }