Skip to content
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

Closed
wants to merge 1 commit into from
Closed

HTTP API: Support float values for default query step #1359

wants to merge 1 commit into from

Conversation

danieldabate
Copy link
Contributor

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

  • Tests updated

@cyriltovena cyriltovena self-requested a review December 3, 2019 21:07
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
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

@danieldabate danieldabate Dec 3, 2019

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

@cyriltovena cyriltovena left a 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.

@cyriltovena
Copy link
Contributor

@danieldabate again thanks a lot for the contribution ! Seems that we don't need this, my bad.

@cyriltovena cyriltovena closed this Dec 5, 2019
@danieldabate
Copy link
Contributor Author

danieldabate commented Dec 5, 2019

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HTTP API: Default step value calculation should support float values
3 participants