-
Notifications
You must be signed in to change notification settings - Fork 516
/
errors.go
62 lines (52 loc) · 2.54 KB
/
errors.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// SPDX-License-Identifier: AGPL-3.0-only
package limiter
import (
"fmt"
"github.com/grafana/mimir/pkg/util/globalerror"
"github.com/grafana/mimir/pkg/util/validation"
)
var (
maxSeriesHitMsgFormat = globalerror.MaxSeriesPerQuery.MessageWithStrategyAndPerTenantLimitConfig(
"the query exceeded the maximum number of series (limit: %d series)",
cardinalityStrategy,
validation.MaxSeriesPerQueryFlag,
)
maxChunkBytesHitMsgFormat = globalerror.MaxChunkBytesPerQuery.MessageWithStrategyAndPerTenantLimitConfig(
"the query exceeded the aggregated chunks size limit (limit: %d bytes)",
cardinalityStrategy,
validation.MaxChunkBytesPerQueryFlag,
)
maxChunksPerQueryLimitMsgFormat = globalerror.MaxChunksPerQuery.MessageWithStrategyAndPerTenantLimitConfig(
"the query exceeded the maximum number of chunks (limit: %d chunks)",
cardinalityStrategy,
validation.MaxChunksPerQueryFlag,
)
maxEstimatedChunksPerQueryLimitMsgFormat = globalerror.MaxEstimatedChunksPerQuery.MessageWithStrategyAndPerTenantLimitConfig(
"the estimated number of chunks for the query exceeded the maximum allowed (limit: %d chunks)",
cardinalityStrategy,
validation.MaxEstimatedChunksPerQueryMultiplierFlag,
)
maxEstimatedMemoryConsumptionPerQueryLimitMsgFormat = globalerror.MaxEstimatedMemoryConsumptionPerQuery.MessageWithStrategyAndPerTenantLimitConfig(
"the query exceeded the maximum allowed estimated amount of memory consumed by a single query (limit: %d bytes)",
cardinalityStrategy,
validation.MaxEstimatedMemoryConsumptionPerQueryFlag,
)
)
func limitError(format string, limit uint64) validation.LimitError {
return validation.NewLimitError(fmt.Sprintf(format, limit))
}
func NewMaxSeriesHitLimitError(maxSeriesPerQuery uint64) validation.LimitError {
return limitError(maxSeriesHitMsgFormat, maxSeriesPerQuery)
}
func NewMaxChunkBytesHitLimitError(maxChunkBytesPerQuery uint64) validation.LimitError {
return limitError(maxChunkBytesHitMsgFormat, maxChunkBytesPerQuery)
}
func NewMaxChunksPerQueryLimitError(maxChunksPerQuery uint64) validation.LimitError {
return limitError(maxChunksPerQueryLimitMsgFormat, maxChunksPerQuery)
}
func NewMaxEstimatedChunksPerQueryLimitError(maxEstimatedChunksPerQuery uint64) validation.LimitError {
return limitError(maxEstimatedChunksPerQueryLimitMsgFormat, maxEstimatedChunksPerQuery)
}
func NewMaxEstimatedMemoryConsumptionPerQueryLimitError(maxEstimatedMemoryConsumptionPerQuery uint64) validation.LimitError {
return limitError(maxEstimatedMemoryConsumptionPerQueryLimitMsgFormat, maxEstimatedMemoryConsumptionPerQuery)
}