Skip to content

Commit 0b47fbd

Browse files
authored
[chore] Make Test_WindowsPerfCounterScraper more resilient (open-telemetry#41197)
The test has some sporadic failures when it hits `A counter with a negative denominator value was detected.` - this is typically a transient error when collecting performance counters on Windows. Similar transient errors could also happen. Making the test more resilient by testing a few times before giving up. Fixes open-telemetry#41136
1 parent af7cf37 commit 0b47fbd

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

receiver/windowsperfcountersreceiver/windowsperfcounters_scraper_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,11 @@ func Test_WindowsPerfCounterScraper(t *testing.T) {
235235
require.Equal(t, 0, obs.Len())
236236
require.NoError(t, err)
237237

238-
actualMetrics, err := scraper.scrape(context.Background())
239-
require.NoError(t, err)
238+
var actualMetrics pmetric.Metrics
239+
require.EventuallyWithT(t, func(c *assert.CollectT) {
240+
actualMetrics, err = scraper.scrape(context.Background())
241+
assert.NoError(c, err)
242+
}, 20*time.Second, 1*time.Second)
240243

241244
err = scraper.shutdown(context.Background())
242245

0 commit comments

Comments
 (0)