linting main.go and exporter.go

This commit is contained in:
lconsuegra 2021-01-07 12:04:03 +01:00
parent 5d5c586337
commit adbca53201
2 changed files with 5 additions and 2 deletions

View File

@ -37,13 +37,16 @@ func main() {
http.Handle(opts.MetricsPath, promhttp.Handler())
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(`<html>
_, err := w.Write([]byte(`<html>
<head><title>Cups Exporter</title></head>
<body>
<h1>Cups Exporter</h1>
<p><a href="` + opts.MetricsPath + `">Metrics</a></p>
</body>
</html>`))
if err != nil {
log.Info("An error occured while writing http response: %v", err)
}
})
log.Info("listening on " + opts.Address)

View File

@ -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)