-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
HTTP API: Support float values for default query step #1359
Conversation
func defaultQueryRangeStep(start time.Time, end time.Time) int { | ||
return int(math.Max(math.Floor(end.Sub(start).Seconds()/250), 1)) | ||
func defaultQueryRangeStep(start time.Time, end time.Time) time.Duration { | ||
return end.Sub(start) / 250 |
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.
Looks like the / 250 was applied to seconds. Now it's applied to nanoseconds. Doesn't that changes the behaviour ?
/cc @pracucci WDYT ? You did that piece.
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.
Yes, the current behaviour changes as can be seen on the tests. Now the range is divided in 250 precise steps. For example, in the previous implementation if you had a range of 1h you would get steps of 14s, and now you would get steps of 14,4s.
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.
Ha that makes sense ! since you returns nanoseconds now.
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.
Also the value is not bounded to 1s anymore. So if you have a range of, let's say, 200seconds you will get steps of 0.8s. I think it makes sense, but maybe someone else with more knowledge on this part will know better.
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.
The change itself doesn't look wrong, but I'm not sure this change brings any real benefit and I'm not getting the reason why we should support steps below 1s. Which use case do we want to cover?
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.
You've got a good point there. There's no real use case at the moment that supports this change. It was just an idea we had with Cyril after pushing this change: #1355
Actually, thinking out loud Prometheus doesn't seem to provide a default value for this parameter, so if we want Loki to have an API matching Prometheus' API, we should remove this feature.
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.
LGTM, I'll wait for Marco as he worked on this.
@danieldabate again thanks a lot for the contribution ! Seems that we don't need this, my bad. |
No problem! You just owe me a beer next time I go to France... no, wait... a pain au chocolat would be better. |
What this PR does / why we need it:
Currently the default value for the step parameter only supports int values with a lower bound of 1s. Supporting floats not only provides a more accurate resolution for the step but also allows us to remove the lower bound.
Which issue(s) this PR fixes:
Fixes #1358
Checklist