-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow NaN as a valid value on the graphite service #4846
Allow NaN as a valid value on the graphite service #4846
Conversation
@@ -117,7 +117,8 @@ func (p *Parser) Parse(line string) (models.Point, error) { | |||
} | |||
|
|||
if math.IsNaN(v) || math.IsInf(v, 0) { | |||
return nil, fmt.Errorf(`field "%s" value: '%v" is unsupported`, fields[0], v) | |||
// Graphite ignores NaN values with no error | |||
return nil, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should return a specific error type and be handled (and ignored) higher up. Returning a nil
error here is problematic with the standard go if err != nil {}
idiom. You now have to check both err
and point
not being nil which is not what a caller would typically expect or do. This func should either return a Point
or an error
.
I've updated this to continue returning an error, but it creates an I wasn't sure if the error value should be exported or not. I also tried to add a test, but unfortunately I didn't find a way to access the error reporting mechanism from the service through a public API. |
|
||
import "fmt" | ||
|
||
type UnsupportedValueError struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use a naming convention with an Err
prefix. So this should be ErrUnsupportedValue
.
@jsternberg Yes. This error should be exported. Not sure I understand the test issue you ran into though. |
@jwilder all I meant was if you remove my change, the tests won't fail. Here's an example of running the tests without my change:
Here's with my change:
It's fixed, but if it gets messed up in some way, the tests won't fail. Unfortunately, the error only appears to be reported into an internal structure (the If there's a better way to check for the error condition, I'll include it in this PR. |
I see. I would add a test to |
Updated the PR. |
switch err := err.(type) { | ||
case *ErrUnsupportedValue: | ||
// Graphite ignores NaN values with no error. | ||
if math.IsNaN(err.Value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's count these, so we have visibility into how many points InfluxDB is dropping due to IsNan
values. I suggest statPointsNanFail
, with the text pointsNanFail
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added it as statPointsNaNFail
(as NaN is usually capitalized that way instead of Nan). If you want the other capitalization, I can amend the commit again.
Makes sense to me, +1. @jwilder ? |
For reference, this is the behavior I'm attempting to replicate: https://github.com/graphite-project/carbon/blob/d3822aa44d637b55839b734f5dcd2de2ce10bef8/lib/carbon/protocols.py#L65 |
@@ -58,6 +58,7 @@ There are breaking changes in this release: | |||
- [#4681](https://github.com/influxdb/influxdb/pull/4681): Increase default buffer size for collectd and graphite listeners | |||
- [#4659](https://github.com/influxdb/influxdb/pull/4659): Support IF EXISTS for DROP DATABASE | |||
- [#4685](https://github.com/influxdb/influxdb/pull/4685): Automatically promote node to raft peer if drop server results in removing a raft peer. | |||
- [#4846](https://github.com/influxdb/influxdb/pull/4846): Allow NaN as a valid value on the graphite service; discard these points silently (graphite compatibilty). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be sure to give yourself credit here, by thanking yourself. :-) Add "thanks @jsternberg" to the end of this line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
compatibilty -> compatibility
👍 |
Thanks @jwilder @jsternberg -- just give yourself credit and we will merge this -- thanks again. |
The canonical graphite implementation will read and discard NaN values instead of throwing an error when reading on the line receiver protocol. Since this is the default behavior for graphite, InfluxDB should have the same behavior for compatibility. Previously, a NaN value would result in an error printed to the console. When you have a large number of NaN values being sent every minute, this results in the log file filling with useless messages.
Done! |
…e-service Allow NaN as a valid value on the graphite service
The canonical graphite implementation will read and discard NaN values
instead of throwing an error when reading on the line receiver protocol.
Since this is the default behavior for graphite, InfluxDB should have
the same behavior for compatibility.
Previously, a NaN value would result in an error printed to the console.
When you have a large number of NaN values being sent every minute, this
results in the log file filling with useless messages.