changed TestThreadStats acc to wait for 2 and added warning comment (#8592)

This commit is contained in:
Helen Weller 2020-12-17 19:32:49 -05:00 committed by GitHub
parent 94eb8f2e42
commit 04e62e3d23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -119,7 +119,7 @@ func TestThreadStats(t *testing.T) {
c.Write([]byte(ex3))
c.Write([]byte("\n"))
c.Close()
acc.Wait(1)
acc.Wait(2)
expected := []telegraf.Metric{
testutil.MustMetric(

View File

@ -54,6 +54,8 @@ func (a *Accumulator) NMetrics() uint64 {
return atomic.LoadUint64(&a.nMetrics)
}
// GetTelegrafMetrics returns all the metrics collected by the accumulator
// If you are getting race conditions here then you are not waiting for all of your metrics to arrive: see Wait()
func (a *Accumulator) GetTelegrafMetrics() []telegraf.Metric {
metrics := []telegraf.Metric{}
for _, m := range a.Metrics {