mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-12 06:17:27 -08:00
Adds Inf and NaN as Numbers to Histogram in Promql Testing Framework (#13916)
includes Inf and NaN as numbers to histogram --------- Signed-off-by: Neeraj Gartia <neerajgartia211002@gmail.com> Signed-off-by: Björn Rabenstein <github@rabenste.in> Co-authored-by: Björn Rabenstein <github@rabenste.in>
This commit is contained in:
parent
2a43026558
commit
612de026da
|
@ -519,7 +519,7 @@ func lexHistogram(l *Lexer) stateFn {
|
|||
return lexHistogram
|
||||
case r == '-':
|
||||
l.emit(SUB)
|
||||
return lexNumber
|
||||
return lexHistogram
|
||||
case r == 'x':
|
||||
l.emit(TIMES)
|
||||
return lexNumber
|
||||
|
@ -568,10 +568,16 @@ Loop:
|
|||
return lexHistogram
|
||||
}
|
||||
l.errorf("missing `:` for histogram descriptor")
|
||||
} else {
|
||||
l.errorf("bad histogram descriptor found: %q", word)
|
||||
break Loop
|
||||
}
|
||||
|
||||
// Current word is Inf or NaN.
|
||||
if desc, ok := key[strings.ToLower(word)]; ok {
|
||||
if desc == NUMBER {
|
||||
l.emit(desc)
|
||||
return lexHistogram
|
||||
}
|
||||
}
|
||||
l.errorf("bad histogram descriptor found: %q", word)
|
||||
break Loop
|
||||
}
|
||||
}
|
||||
|
|
|
@ -561,6 +561,35 @@ var tests = []struct {
|
|||
},
|
||||
seriesDesc: true,
|
||||
},
|
||||
{ // Series with sum as -Inf and count as NaN.
|
||||
input: `{} {{buckets: [5 10 7] sum:Inf count:NaN}}`,
|
||||
expected: []Item{
|
||||
{LEFT_BRACE, 0, `{`},
|
||||
{RIGHT_BRACE, 1, `}`},
|
||||
{SPACE, 2, ` `},
|
||||
{OPEN_HIST, 3, `{{`},
|
||||
{BUCKETS_DESC, 5, `buckets`},
|
||||
{COLON, 12, `:`},
|
||||
{SPACE, 13, ` `},
|
||||
{LEFT_BRACKET, 14, `[`},
|
||||
{NUMBER, 15, `5`},
|
||||
{SPACE, 16, ` `},
|
||||
{NUMBER, 17, `10`},
|
||||
{SPACE, 19, ` `},
|
||||
{NUMBER, 20, `7`},
|
||||
{RIGHT_BRACKET, 21, `]`},
|
||||
{SPACE, 22, ` `},
|
||||
{SUM_DESC, 23, `sum`},
|
||||
{COLON, 26, `:`},
|
||||
{NUMBER, 27, `Inf`},
|
||||
{SPACE, 30, ` `},
|
||||
{COUNT_DESC, 31, `count`},
|
||||
{COLON, 36, `:`},
|
||||
{NUMBER, 37, `NaN`},
|
||||
{CLOSE_HIST, 40, `}}`},
|
||||
},
|
||||
seriesDesc: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue