File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -387,7 +387,9 @@ func Parse(s string) (float64, error) {
387
387
if strings .HasPrefix (ss , "+" ) {
388
388
ss = ss [1 :]
389
389
}
390
- if strings .EqualFold (ss , "inf" ) {
390
+ // "infinity" is needed for OpenMetrics support.
391
+ // See https://github.com/OpenObservability/OpenMetrics/blob/master/OpenMetrics.md
392
+ if strings .EqualFold (ss , "inf" ) || strings .EqualFold (ss , "infinity" ) {
391
393
if minus {
392
394
return - inf , nil
393
395
}
Original file line number Diff line number Diff line change @@ -457,6 +457,10 @@ func TestParseSuccess(t *testing.T) {
457
457
f ("-Inf" , math .Inf (- 1 ))
458
458
f ("+iNf" , math .Inf (1 ))
459
459
f ("INF" , math .Inf (1 ))
460
+ f ("infinity" , math .Inf (1 ))
461
+ f ("-Infinity" , math .Inf (- 1 ))
462
+ f ("+iNfINIty" , math .Inf (1 ))
463
+ f ("INFINITY" , math .Inf (1 ))
460
464
f ("nan" , math .NaN ())
461
465
f ("-nan" , math .NaN ())
462
466
f ("naN" , math .NaN ())
You can’t perform that action at this time.
0 commit comments