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

fix: don't collect system.cpu.utilization per-cpu #4716

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 @@ -60,7 +60,8 @@ func (s *scraper) start(ctx context.Context, _ component.Host) error {
func (s *scraper) scrape(ctx context.Context) (pmetric.Metrics, error) {
ctx = context.WithValue(ctx, common.EnvKey, s.config.EnvMap)
now := pcommon.NewTimestampFromTime(s.now())
cpuTimes, err := s.times(ctx, true /*percpu=*/)
// set percpu=false to support Windows 7
cpuTimes, err := s.times(ctx, false /*percpu=*/)
if err != nil {
return pmetric.NewMetrics(), scrapererror.NewPartialScrapeError(err, metricsLen)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,10 @@ func assertCPUMetricValid(t *testing.T, metric pmetric.Metric, startTime pcommon
if startTime != 0 {
internal.AssertSumMetricStartTimeEquals(t, metric, startTime)
}
assert.GreaterOrEqual(t, metric.Sum().DataPoints().Len(), 4*runtime.NumCPU())
cpuUtilizationStates := []string{"user", "system", "idle", "interrupt"}

// CPU time is not per-CPU, just assert we collected at least one metric for each state
assert.GreaterOrEqual(t, metric.Sum().DataPoints().Len(), len(cpuUtilizationStates))
internal.AssertSumMetricHasAttribute(t, metric, 0, "cpu")
internal.AssertSumMetricHasAttributeValue(t, metric, 0, "state",
pcommon.NewValueStr(metadata.AttributeStateUser.String()))
Expand Down
Loading