Skip to content

Commit

Permalink
fix: Check for negative values in agg metrics
Browse files Browse the repository at this point in the history
* If agg metrics is negative, return 0

Signed-off-by: Mahendra Paipuri <[email protected]>
  • Loading branch information
mahendrapaipuri committed Apr 6, 2024
1 parent c7a3eb5 commit b53e768
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/api/updater/tsdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,9 @@ func (t *tsdbUpdater) deleteTimeSeries(startTime time.Time, endTime time.Time, u
}

// sanitizeValue verifies if value is either NaN/Inf/-Inf.
// If value is any of these, zero will be returned
// If value is any of these, zero will be returned. Returns 0 if value is negative
func sanitizeValue(val float64) models.JSONFloat {
if math.IsNaN(val) || math.IsInf(val, 0) {
if math.IsNaN(val) || math.IsInf(val, 0) || val < 0 {
return models.JSONFloat(0)
}
return models.JSONFloat(val)
Expand Down

0 comments on commit b53e768

Please sign in to comment.