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

Log when returning query-time limit #8938

Merged
merged 1 commit into from
Mar 29, 2023
Merged

Conversation

salvacorts
Copy link
Contributor

What this PR does / why we need it:
At #8727 we introduced various limits that can now be configured at query time. We always compare the value of the limit configured at query time with the value set on the overrides for the tenant or the default if not configured (aka original); applying the most restrictive one.

If the most restrictive is the original value or the limit is not configured at query-time, we print the following debug message:

level.Debug(logutil.WithContext(ctx, l.logger)).Log("msg", "using original limit")

It will be printed many times: every time the query is not configured at query-time, as well as every time the original value is more restrictive. Moreover, this log message lacks some useful information such as the original value, the query-time value, the tenant ID and the limit name.

This PR fixes this by removing the debug message above and printing a new debug message only if we return the query-time limit. This new log also prints the tenant ID, the limit name, as well as the original and the query-time limit values.

Which issue(s) this PR fixes:
Fixes #8932

Special notes for your reviewer:

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • CHANGELOG.md updated
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/upgrading/_index.md

return original
}
level.Debug(logutil.WithContext(ctx, l.logger)).Log("msg", "using request limit", "limit", requestLimits.MaxQueryLength)
level.Debug(logutil.WithContext(ctx, l.logger)).Log("msg", "using request limit", "limit", "MaxQueryLength", "tenant", userID, "query-limit", requestLimits.MaxQueryLength, "original-limit", original)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we need to print the limit name? I'd say we don't since the logger will print the line where we are calling level.Debug.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's easier if the limit name is printed as well.

@salvacorts salvacorts marked this pull request as ready for review March 29, 2023 10:59
@salvacorts salvacorts requested a review from a team as a code owner March 29, 2023 10:59
@salvacorts salvacorts changed the title Log when returning query-time limit. Also added more info to log message Log when returning query-time limit Mar 29, 2023
return original
}
level.Debug(logutil.WithContext(ctx, l.logger)).Log("msg", "using request limit", "limit", requestLimits.MaxQueryLength)
level.Debug(logutil.WithContext(ctx, l.logger)).Log("msg", "using request limit", "limit", "MaxQueryLength", "tenant", userID, "query-limit", requestLimits.MaxQueryLength, "original-limit", original)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's easier if the limit name is printed as well.

@salvacorts salvacorts merged commit d421fea into main Mar 29, 2023
@salvacorts salvacorts deleted the salvacorts/log-query-time-limit branch March 29, 2023 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Usefulness of logging in query-time limits.
2 participants