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

feat(ingest-limits): Add ExceedsLimit implementation #15884

Merged
merged 9 commits into from
Jan 23, 2025

Conversation

periklis
Copy link
Collaborator

@periklis periklis commented Jan 22, 2025

What this PR does / why we need it:
Implements the ExceedsLimit GRPC request handler for requesting stream counts per tenant. The implementation currently is:

  1. Counting the total active streams for a tenant by remove duplicates.
  2. Records which of the requested stream hashes are not recorded by any metadata partition and rejects them if max active streams reached.

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:

Checklist

  • Reviewed the CONTRIBUTING.md guide (required)
  • Documentation added
  • Tests updated
  • Title matches the required conventional commits format, see here
    • Note that Promtail is considered to be feature complete, and future development for logs collection will be in Grafana Alloy. As such, feat PRs are unlikely to be accepted unless a case can be made for the feature actually being a bug fix to existing behavior.
  • Changes that require user attention or interaction to upgrade are documented in docs/sources/setup/upgrade/_index.md
  • If the change is deprecating or removing a configuration option, update the deprecated-config.yaml and deleted-config.yaml files respectively in the tools/deprecated-config-checker directory. Example PR

@periklis periklis self-assigned this Jan 22, 2025
@periklis periklis requested a review from a team as a code owner January 22, 2025 18:17
Copy link
Contributor

@grobinson-grafana grobinson-grafana left a comment

Choose a reason for hiding this comment

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

Excellent work! A couple of questions, but otherwise LGTM!

for _, resp := range resps {
sum += resp.Response.(*logproto.GetStreamUsageResponse).ActiveStreams
if resp.Response == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a case where a resp.Response can be nil when err is also non-nil?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No I guess it was just muscle memory to protect from nil rather than considering the code branches. This if-statement is obsolete.

// recorded
for _, stream := range resp.Response.RecordedStreams {
if !uniqueStreamHashes[stream.StreamHash] {
uniqueStreamHashes[stream.StreamHash] = true
Copy link
Contributor

Choose a reason for hiding this comment

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

I find the code easier to read if we increment unique streams inside the if statement, instead of add the total and then subtract the duplicates. Is the latter much faster?

@github-actions github-actions bot added the type/docs Issues related to technical documentation; the Docs Squad uses this label across many repositories label Jan 23, 2025
Copy link
Contributor

github-actions bot commented Jan 23, 2025

💻 Deploy preview deleted.

@periklis periklis merged commit 20da94c into feat/usage-tracker Jan 23, 2025
61 checks passed
@periklis periklis deleted the exceed-limits-response-handler branch January 23, 2025 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/XL type/docs Issues related to technical documentation; the Docs Squad uses this label across many repositories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants