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

Make default search limit configurable #1022

Merged
merged 7 commits into from
Oct 12, 2021
Merged

Conversation

kvrhdn
Copy link
Member

@kvrhdn kvrhdn commented Oct 11, 2021

What this PR does:
Adds a configuration parameter querier.search_default_limit which allows you to set a server-side default.

Which issue(s) this PR fixes:
Part of #932

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

Copy link
Member

@mapno mapno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some minor comments.

The new param should be added to the config docs.

modules/querier/http.go Outdated Show resolved Hide resolved
docs/tempo/website/configuration/_index.md Outdated Show resolved Hide resolved
maxResults := int(req.Limit)
// limit should always be set, if it's missing set a safe default
if maxResults == 0 {
maxResults = 100
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line should never be reached correct? It's the main purpose of the PR

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this line should never be reached. I wanted to add it as an extra safety check, just in case someone sends a query directly to the ingester. But this should be pretty much impossible as it's pretty hard to send a grpc request.
Protecting against 0 also doesn't make a lot of sense and it can never be negative 😅

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I opted to re-add the check again as req.Limit == 0 is most likely an indication that the caller didn't bother to set the limit. It's unlikely they explicitly wanted a limit of 0. If the limit is unset I think we should simply use a safe default limit.

modules/querier/querier.go Outdated Show resolved Hide resolved
modules/ingester/instance_search.go Outdated Show resolved Hide resolved
@kvrhdn kvrhdn requested a review from annanay25 October 12, 2021 08:53
Copy link
Contributor

@annanay25 annanay25 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@kvrhdn kvrhdn merged commit ddbfd51 into grafana:main Oct 12, 2021
@kvrhdn kvrhdn deleted the search-limit branch October 12, 2021 10:20
Copy link
Contributor

@KMiller-Grafana KMiller-Grafana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs look good to me.

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.

None yet

4 participants