Closed fionaliao closed 1 year ago
This PR makes infinity handling in carbonapi closer to graphite-web behaviour.
In graphite-web, the second parameter for the functions keepLastValue and interpolate is intOrInf, with the default being INF
keepLastValue
interpolate
intOrInf
INF
Currently carbonapi treats the second parameter as a float that could be infinity.
graphite-web does not allow floats apart from infinity for this parameter: https://github.com/graphite-project/graphite-web/blob/dca59dc72ae28ffdae659232c10c60aa598536eb/webapp/graphite/functions/params.py#L64-L77
This PR introduces an InfOrInf type that behaves like graphite-web for these two functions.
InfOrInf
In graphite-web, infinity values in suggestions are marshalled to 1e9999 in JSON, as infinity is not valid for browsers/nodejs
1e9999
See: https://github.com/graphite-project/graphite-web/blob/dca59dc72ae28ffdae659232c10c60aa598536eb/webapp/graphite/functions/views.py#L9 and https://github.com/graphite-project/graphite-web/pull/2612.
Therefore I've updated the suggestion struct marshalling function to replace infinity with 1e9999 to match graphite-web behaviour.
This PR makes infinity handling in carbonapi closer to graphite-web behaviour.
IntOrInf parameter
In graphite-web, the second parameter for the functions
keepLastValue
andinterpolate
isintOrInf
, with the default beingINF
Currently carbonapi treats the second parameter as a float that could be infinity.
graphite-web does not allow floats apart from infinity for this parameter: https://github.com/graphite-project/graphite-web/blob/dca59dc72ae28ffdae659232c10c60aa598536eb/webapp/graphite/functions/params.py#L64-L77
This PR introduces an
InfOrInf
type that behaves like graphite-web for these two functions.Inf marshalling
In graphite-web, infinity values in suggestions are marshalled to
1e9999
in JSON, as infinity is not valid for browsers/nodejsSee: https://github.com/graphite-project/graphite-web/blob/dca59dc72ae28ffdae659232c10c60aa598536eb/webapp/graphite/functions/views.py#L9 and https://github.com/graphite-project/graphite-web/pull/2612.
Therefore I've updated the suggestion struct marshalling function to replace infinity with 1e9999 to match graphite-web behaviour.