Skip to content
This repository was archived by the owner on Jan 10, 2023. It is now read-only.

Commit afe5326

Browse files
committed
2 parents 8a91e6f + c47462c commit afe5326

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

metric.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,22 @@ type cmetric struct {
2121
typ prometheus.ValueType
2222
}
2323

24+
func parseFloatOrBool(v string) (float64, error) {
25+
f, err := strconv.ParseFloat(v, 64)
26+
if err != nil {
27+
// trying to see if the value is a boolean
28+
b, err2 := strconv.ParseBool(v)
29+
if err2 == nil {
30+
err = nil
31+
f = 0
32+
if b {
33+
f = 1
34+
}
35+
}
36+
}
37+
return f, err
38+
}
39+
2440
// infoCollect parses RequestInfo() results and handles the metrics
2541
func infoCollect(
2642
ch chan<- prometheus.Metric,
@@ -35,7 +51,7 @@ func infoCollect(
3551
// key presence depends on (namespace) configuration
3652
continue
3753
}
38-
f, err := strconv.ParseFloat(v, 64)
54+
f, err := parseFloatOrBool(v)
3955
if err != nil {
4056
log.Printf("%q invalid value %q: %s", key, v, err)
4157
continue

namespaces.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ var (
2222
gauge("prole_tombstones", "prole tombstones"),
2323
gauge("non_replica_objects", "non replica objects"),
2424
gauge("non_replica_tombstones", "non replica tombstones"),
25-
// stop_writes=false
26-
// hwm_breached=false
25+
gauge("stop_writes", "stop writes"),
26+
gauge("hwm_breached", "hwm breached"),
2727
// current_time=257114127
2828
gauge("non_expirable_objects", "non expirable objects"),
2929
counter("expired_objects", "expired objects"),

0 commit comments

Comments
 (0)