From 62dfbd0112ffcf4a8847b0df3dfcb06ceeaf3e51 Mon Sep 17 00:00:00 2001 From: Yannig Perre Date: Fri, 17 Nov 2023 09:26:07 +0100 Subject: [PATCH] :pencil2: Fix ide warning --- collector/collector.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/collector/collector.go b/collector/collector.go index 3278b167..928c2711 100644 --- a/collector/collector.go +++ b/collector/collector.go @@ -277,7 +277,7 @@ func (e *Exporter) scrape(ch chan<- prometheus.Metric) { wg.Add(1) metric := metric //https://golang.org/doc/faq#closures_and_goroutines - go func() { + f := func() { defer wg.Done() level.Debug(e.logger).Log("About to scrape metric: ") @@ -317,7 +317,8 @@ func (e *Exporter) scrape(ch chan<- prometheus.Metric) { } else { level.Debug(e.logger).Log("Successfully scraped metric: ", metric.Context, metric.MetricsDesc, time.Since(scrapeStart)) } - }() + } + go f() } wg.Wait() } @@ -516,8 +517,8 @@ func (e *Exporter) generatePrometheusMetrics(db *sql.DB, parse func(row map[stri defer cancel() rows, err := db.QueryContext(ctx, query) - if ctx.Err() == context.DeadlineExceeded { - return errors.New("Oracle query timed out") + if errors.Is(ctx.Err(), context.DeadlineExceeded) { + return errors.New("oracle query timed out") } if err != nil {