From adbca53201b68cc5103b2295a87baa47cf8dddb8 Mon Sep 17 00:00:00 2001 From: lconsuegra Date: Thu, 7 Jan 2021 12:04:03 +0100 Subject: [PATCH] linting main.go and exporter.go --- main.go | 5 ++++- pkg/exporter.go | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 83ef164..742ac91 100644 --- a/main.go +++ b/main.go @@ -37,13 +37,16 @@ func main() { http.Handle(opts.MetricsPath, promhttp.Handler()) http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { - w.Write([]byte(` + _, err := w.Write([]byte(` Cups Exporter

Cups Exporter

Metrics

`)) + if err != nil { + log.Info("An error occured while writing http response: %v", err) + } }) log.Info("listening on " + opts.Address) diff --git a/pkg/exporter.go b/pkg/exporter.go index 47f8283..c7e048c 100644 --- a/pkg/exporter.go +++ b/pkg/exporter.go @@ -112,7 +112,7 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) { cupsUp = 0 } - scrapeDuration := time.Now().Sub(scrapeStartTime) + scrapeDuration := time.Since(scrapeStartTime) ch <- prometheus.MustNewConstMetric(e.scrapeDurationSeconds, prometheus.GaugeValue, scrapeDuration.Seconds()) ch <- prometheus.MustNewConstMetric(e.cupsUp, prometheus.GaugeValue, cupsUp)