InvalidTimeInterval thrown for date range before data present
Imported from https://bugs.launchpad.net/bugs/960031
| Reported by | david-henderson |
| Date Created | Mar 20, 2012 |
I have a metric recorded to graphite that I want to produce a historical view for (e.g. the count in 2 months ago, last month and so far this month)
To do this, I am using the URL API with JSON formatting, using a summarise function over a fixed set of dates:
http://127.0.0.1:8804/render?from=20110202&until=20110303&target=summarize(my.metric, "29days")&format=json
This works fine if there is data in the range, but as soon as there isn't, an 500 with an InvalidTimeException is thrown:
Exception Type: InvalidTimeInterval Exception Value: Invalid time interval Exception Location: /usr/local/lib/python2.7/dist-packages/whisper.py in file_fetch, line 659
This appears to originate from this part of file_fetch.py:
oldestTime = now - header['maxRetention'] if fromTime < oldestTime: fromTime = oldestTime
if not (fromTime < untilTime): raise InvalidTimeInterval("Invalid time interval")
The from time appears to be being advanced to a point after the until time, making it invalid.
In this situation, I think a null or zero value should be returned rather than throwing an exception?
Comment by bennett on Jun 12, 2012:
I agree that the result should be an empty or null dataset, rather than an exception. Perhaps instead of advancing the fromTime and untilTime, whisper could correctly calculate any subset of the requested interval that overlaps the retention period, and return data from that subset. If the requested interval completely misses the retention window, just return a base case of null or an empty data array.
Hello, is there any news on this one, we are still hit by that one a fair bit :/
+1
also getting bitten by this relatively often.
+1
+1
+1
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.