Fix leaking context in openmetrics source.
@@ -120,6 +120,7 @@ intervalLoop:
for {
select {
case t := <-ticker.C:
+ func() {
ctx, cancel :=
context.WithDeadline(source.context, t.Add(source.ScrapeTimeout))
defer cancel()
@@ -127,16 +128,17 @@ intervalLoop:
if err != nil {
source.logger.WithError(err).Warn("failed to query metrics")
- continue
+ return
}
udpMetrics := source.Convert(results)
for metric := range udpMetrics {
if metric.Error != nil {
source.logger.WithError(err).Warn("failed to ingest metrics")
- continue intervalLoop
+ return
}
ingest.IngestMetric(metric.Metric)
}
+ }()
case <-source.context.Done():
break intervalLoop
}
