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

max_global_traces_per_user: take into account ingestion.tenant_shard_size when converting to local limit #3618

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* [ENHANCEMENT] Improve use of OTEL semantic conventions on the service graph [#3711](https://github.com/grafana/tempo/pull/3711) (@zalegrala)
* [ENHANCEMENT] Performance improvement for `rate() by ()` queries [#3719](https://github.com/grafana/tempo/pull/3719) (@mapno)
* [BUGFIX] Fix metrics queries when grouping by attributes that may not exist [#3734](https://github.com/grafana/tempo/pull/3734) (@mdisibio)
* [BUGFIX] max_global_traces_per_user: take into account ingestion.tenant_shard_size when converting to local limit [#3618](https://github.com/grafana/tempo/pull/3618) (@kvrhdn)

## v2.5.0

Expand Down
8 changes: 5 additions & 3 deletions modules/ingester/limiter.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (l *Limiter) maxTracesPerUser(userID string) int {
// We can assume that traces are evenly distributed across ingesters
// so we do convert the global limit into a local limit
globalLimit := l.limits.MaxGlobalTracesPerUser(userID)
localLimit = l.minNonZero(localLimit, l.convertGlobalToLocalLimit(globalLimit))
localLimit = l.minNonZero(localLimit, l.convertGlobalToLocalLimit(userID, globalLimit))

// If both the local and global limits are disabled, we just
// use the largest int value
Expand All @@ -65,7 +65,7 @@ func (l *Limiter) maxTracesPerUser(userID string) int {
return localLimit
}

func (l *Limiter) convertGlobalToLocalLimit(globalLimit int) int {
func (l *Limiter) convertGlobalToLocalLimit(userID string, globalLimit int) int {
if globalLimit == 0 {
return 0
}
Expand All @@ -74,7 +74,9 @@ func (l *Limiter) convertGlobalToLocalLimit(globalLimit int) int {
// topology changes) and we prefer to always be in favor of the tenant,
// we can use a per-ingester limit equal to:
// (global limit / number of ingesters) * replication factor
numIngesters := l.ring.HealthyInstancesCount()
ingestionShardSize := l.limits.IngestionTenantShardSize(userID)
totalIngesters := l.ring.HealthyInstancesCount()
numIngesters := l.minNonZero(ingestionShardSize, totalIngesters)

// May happen because the number of ingesters is asynchronously updated.
// If happens, we just temporarily ignore the global limit.
Expand Down
Loading