Sfoglia il codice sorgente

Merge branch 'bolt/cluster-metrics-refactor' of github.com:kubecost/cost-model into AjayTripathy-guard-nan

AjayTripathy 6 anni fa
parent
commit
635e322865
1 ha cambiato i file con 5 aggiunte e 1 eliminazioni
  1. 5 1
      costmodel/promparsers.go

+ 5 - 1
costmodel/promparsers.go

@@ -151,7 +151,11 @@ func parseDataPoint(dataPoint interface{}, labels func() string) (*Vector, error
 		return nil, err
 	}
 
-	if math.IsNaN(v) {
+	// Test for +Inf and -Inf (sign: 0), Test for NaN
+	if math.IsInf(v, 0) {
+		klog.V(1).Infof("[Warning] Found Inf value parsing vector data point for metric: %s", labels())
+		v = 0.0
+	} else if math.IsNaN(v) {
 		klog.V(1).Infof("[Warning] Found NaN value parsing vector data point for metric: %s", labels())
 		v = 0.0
 	}