@@ -266,22 +266,27 @@ func newMetricsCollector(config *metricsCollectorConfig, labels map[string]strin
266
266
}
267
267
}
268
268
269
+ func (mc * metricsCollector ) init () {
270
+ // Reset the metrics so that the measurements do not interfere with those collected during the previous steps.
271
+ legacyregistry .Reset ()
272
+ }
273
+
269
274
func (* metricsCollector ) run (tCtx ktesting.TContext ) {
270
275
// metricCollector doesn't need to start before the tests, so nothing to do here.
271
276
}
272
277
273
- func (pc * metricsCollector ) collect () []DataItem {
278
+ func (mc * metricsCollector ) collect () []DataItem {
274
279
var dataItems []DataItem
275
- for metric , labelValsSlice := range pc .Metrics {
280
+ for metric , labelValsSlice := range mc .Metrics {
276
281
// no filter is specified, aggregate all the metrics within the same metricFamily.
277
282
if labelValsSlice == nil {
278
- dataItem := collectHistogramVec (metric , pc .labels , nil )
283
+ dataItem := collectHistogramVec (metric , mc .labels , nil )
279
284
if dataItem != nil {
280
285
dataItems = append (dataItems , * dataItem )
281
286
}
282
287
} else {
283
288
for _ , lvMap := range uniqueLVCombos (labelValsSlice ) {
284
- dataItem := collectHistogramVec (metric , pc .labels , lvMap )
289
+ dataItem := collectHistogramVec (metric , mc .labels , lvMap )
285
290
if dataItem != nil {
286
291
dataItems = append (dataItems , * dataItem )
287
292
}
@@ -370,7 +375,7 @@ type throughputCollector struct {
370
375
errorMargin float64
371
376
}
372
377
373
- func newThroughputCollector (tb ktesting. TB , podInformer coreinformers.PodInformer , labels map [string ]string , namespaces []string , errorMargin float64 ) * throughputCollector {
378
+ func newThroughputCollector (podInformer coreinformers.PodInformer , labels map [string ]string , namespaces []string , errorMargin float64 ) * throughputCollector {
374
379
return & throughputCollector {
375
380
podInformer : podInformer ,
376
381
labels : labels ,
@@ -379,6 +384,9 @@ func newThroughputCollector(tb ktesting.TB, podInformer coreinformers.PodInforme
379
384
}
380
385
}
381
386
387
+ func (tc * throughputCollector ) init () {
388
+ }
389
+
382
390
func (tc * throughputCollector ) run (tCtx ktesting.TContext ) {
383
391
podsScheduled , _ , err := getScheduledPods (tc .podInformer , tc .namespaces ... )
384
392
if err != nil {
0 commit comments