fix(metricprovider): fix handling null values in datadog #3893
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Checklist:
"fix(controller): Updates such and such. Fixes #1234"
.When Datadog returns a values list with JSON
null
value, instead of an empty slice, it gets unmarshalled to a float64 value of 0, which is not what should happen (should be treated as if an empty slice). This is becausevalues
is a[]float64
. Switching it to[]*float64
fixes this issue.I've encountered this issue when doing zero/zero division. For example in
a/(a+b)
, wherea
andb
are both zeros, thea/(a+b)
formula returnsnull
. I'm sure this could happen in other cases but I'm not aware of them.For reference, this is what the datadog response would look like:
For the numerator and denominator
I've built and tested the image. No need for additional unit tests.