Accumulator.AddError() interface instead of returning err
This commit is contained in:
parent
e46e9ab79c
commit
43a9b37eab
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue