Skip to content

Commit

Permalink
chore: update process summary
Browse files Browse the repository at this point in the history
  • Loading branch information
VihasMakwana committed Jul 18, 2024
1 parent 21b102b commit 51a7854
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
10 changes: 5 additions & 5 deletions metricbeat/module/system/process_summary/process_summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
// descriptive error must be returned.
func (m *MetricSet) Fetch(r mb.ReporterV2) error {

procList, err := process.ListStates(m.sys)
if err != nil {
return fmt.Errorf("error fetching process list: %w", err)
procList, degradeErr := process.ListStates(m.sys)
if degradeErr != nil && !process.IsDegradable(degradeErr) {
return fmt.Errorf("error fetching process list: %w", degradeErr)
}

procStates := map[string]int{}
Expand All @@ -83,7 +83,7 @@ func (m *MetricSet) Fetch(r mb.ReporterV2) error {
}

outMap := mapstr.M{}
err = typeconv.Convert(&outMap, procStates)
err := typeconv.Convert(&outMap, procStates)
if err != nil {
return fmt.Errorf("error formatting process stats: %w", err)
}
Expand All @@ -101,7 +101,7 @@ func (m *MetricSet) Fetch(r mb.ReporterV2) error {
MetricSetFields: outMap,
})

return nil
return degradeErr
}

// threadStats returns a map of state counts for running threads on a system
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ func TestFetch(t *testing.T) {
f := mbtest.NewReportingMetricSetV2Error(t, getConfig())
events, errs := mbtest.ReportingFetchV2Error(f)

require.Empty(t, errs)
for _, err := range errs {
assert.True(t, process.IsDegradable(err))
}
require.NotEmpty(t, events)
event := events[0].BeatEvent("system", "process_summary").Fields
t.Logf("%s/%s event: %+v", f.Module().Name(), f.Name(),
Expand All @@ -62,7 +64,9 @@ func TestStateNames(t *testing.T) {
f := mbtest.NewReportingMetricSetV2Error(t, getConfig())
events, errs := mbtest.ReportingFetchV2Error(f)

require.Empty(t, errs)
for _, err := range errs {
assert.True(t, process.IsDegradable(err))
}
require.NotEmpty(t, events)
event := events[0].BeatEvent("system", "process_summary").Fields

Expand Down

0 comments on commit 51a7854

Please sign in to comment.