From 8056287c91346789b5670eb67110e1d901cd67d0 Mon Sep 17 00:00:00 2001 From: Michael Aldridge Date: Tue, 9 Mar 2021 23:12:37 -0800 Subject: [PATCH] Log when time parsing fails --- main.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 4f6a7a8..614d6e2 100644 --- a/main.go +++ b/main.go @@ -6,6 +6,7 @@ import ( "net/http" "strconv" "time" + "log" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" @@ -44,7 +45,10 @@ func doProbe(w http.ResponseWriter, r *http.Request) { var otime float64 if c == 200 { // If this fails it will just stay at zero; acceptable. - otime, _ = strconv.ParseFloat(string(otimes), 64) + otime, err = strconv.ParseFloat(string(otimes), 64) + if err != nil { + log.Println("Error parsing otime", err) + } } stimeStarts, c, err := fetch("http://" + target + "/stime-start") @@ -54,7 +58,10 @@ func doProbe(w http.ResponseWriter, r *http.Request) { var stimeStart float64 if c == 200 { // If this fails it will just stay at zero; acceptable. - stimeStart, _ = strconv.ParseFloat(string(stimeStarts), 64) + stimeStart, err = strconv.ParseFloat(string(stimeStarts), 64) + if err != nil { + log.Println("Error parsing stimeStart", err) + } } stimeEnds, c, err := fetch("http://" + target + "/stime-end") if err != nil { @@ -63,7 +70,10 @@ func doProbe(w http.ResponseWriter, r *http.Request) { var stimeEnd float64 if c == 200 { // If this fails it will just stay at zero; acceptable. - stimeEnd, _ = strconv.ParseFloat(string(stimeEnds), 64) + stimeEnd, err = strconv.ParseFloat(string(stimeEnds), 64) + if err != nil { + log.Println("Error parsing stimeEnd", err) + } } var (