Skip to content

Commit

Permalink
migrate traefik module to ReporterV2 error (elastic#11458)
Browse files Browse the repository at this point in the history
  • Loading branch information
berfinsari authored and ruflin committed Mar 28, 2019
1 parent 5764e89 commit dcd98bd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions metricbeat/module/traefik/health/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,10 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) {

// Fetch methods gather data, convert it to the right format, and publish it.
// If there are errors, those are published instead.
func (m *MetricSet) Fetch(report mb.ReporterV2) {
func (m *MetricSet) Fetch(reporter mb.ReporterV2) error {
data, err := m.http.FetchJSON()
if err != nil {
report.Error(errors.Wrap(err, "failed to sample health"))
return
return errors.Wrap(err, "failed to sample health")
}

metricSetFields, _ := eventMapping(data)
Expand All @@ -77,5 +76,6 @@ func (m *MetricSet) Fetch(report mb.ReporterV2) {
}
event.RootFields.Put("service.name", "traefik")

report.Event(event)
reporter.Event(event)
return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestFetch(t *testing.T) {

makeBadRequest(config)

ms := mbtest.NewReportingMetricSetV2(t, config)
ms := mbtest.NewReportingMetricSetV2Error(t, config)
reporter := &mbtest.CapturingReporterV2{}

ms.Fetch(reporter)
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/traefik/health/health_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestFetchEventContents(t *testing.T) {
"hosts": []string{server.URL},
}

fetcher := mbtest.NewReportingMetricSetV2(t, config)
fetcher := mbtest.NewReportingMetricSetV2Error(t, config)
reporter := &mbtest.CapturingReporterV2{}

fetcher.Fetch(reporter)
Expand Down

0 comments on commit dcd98bd

Please sign in to comment.