Skip to content

Commit

Permalink
Log when time parsing fails
Browse files Browse the repository at this point in the history
  • Loading branch information
the-maldridge committed Mar 10, 2021
1 parent 8c46663 commit 8056287
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net/http"
"strconv"
"time"
"log"

"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
Expand Down Expand Up @@ -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")
Expand All @@ -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 {
Expand All @@ -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 (
Expand Down

0 comments on commit 8056287

Please sign in to comment.