Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[metricbeat] Migrate windows/perfmon to reporterv2 with error #13517

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ func TestData(t *testing.T) {
},
}

ms := mbtest.NewReportingMetricSetV2(t, config)
mbtest.ReportingFetchV2(ms)
ms := mbtest.NewReportingMetricSetV2Error(t, config)
mbtest.ReportingFetchV2Error(ms)
time.Sleep(60 * time.Millisecond)

events, errs := mbtest.ReportingFetchV2(ms)
events, errs := mbtest.ReportingFetchV2Error(ms)
if len(errs) > 0 {
t.Fatal(errs)
}
Expand All @@ -87,11 +87,11 @@ func TestCounterWithNoInstanceName(t *testing.T) {
},
}

ms := mbtest.NewReportingMetricSetV2(t, config)
mbtest.ReportingFetchV2(ms)
ms := mbtest.NewReportingMetricSetV2Error(t, config)
mbtest.ReportingFetchV2Error(ms)
time.Sleep(60 * time.Millisecond)

events, errs := mbtest.ReportingFetchV2(ms)
events, errs := mbtest.ReportingFetchV2Error(ms)
if len(errs) > 0 {
t.Fatal(errs)
}
Expand Down
14 changes: 9 additions & 5 deletions metricbeat/module/windows/perfmon/perfmon.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,21 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
}, nil
}

func (m *MetricSet) Fetch(report mb.ReporterV2) {
// Fetch fetches events and reports them upstream
func (m *MetricSet) Fetch(report mb.ReporterV2) error {
fearful-symmetry marked this conversation as resolved.
Show resolved Hide resolved
events, err := m.reader.Read()
if err != nil {
m.log.Debugw("Failed reading counters", "error", err)
err = errors.Wrap(err, "failed reading counters")
report.Error(err)
return errors.Wrap(err, "failed reading counters")
}

for _, event := range events {
report.Event(event)
isOpen := report.Event(event)
if !isOpen {
break
}
}

return nil
}

// Close will be called when metricbeat is stopped, should close the query.
Expand Down