Change no data behavior #20
Merged
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.
The current behavior is to raise exception in the constructor of the GraphiteRecord object when a metric with zero values is loaded. This causes all of the other metrics (which could be fine) not to be loaded. In the example render API output for our disk usage gauges, the machine `disk.east.app2' is reporting metrics anymore after a statsd reset so gauge was reset. It would make the load of all of the other metrics fail.
The proposed change here sets a flag on the GraphiteRecord object if it does not contain any values. The list comprehension to generate the input to the check method has been modified to give None instead of the value for the metric (still no divide by zero errors). The None is then detected in the check method and a critical log message is logged for only that metric. The other metrics can still be processed. Additionally, the raise of the exception is moved to be triggered if the entire metrics response is empty.
The behavior for an empty metric is logging it as critical. I am open to changing the behavior in the future, possibly to something like `insufficient_data' like in AWS. Currently, I was just mirroring the level of the previous behavior.