Skip to content

Commit

Permalink
Use uint64 for limit
Browse files Browse the repository at this point in the history
Signed-off-by: Dimitar Dimitrov <dimitar.dimitrov@grafana.com>
  • Loading branch information
dimitarvdimitrov committed Apr 3, 2024
1 parent d750bb4 commit 81b3329
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions pkg/frontend/querymiddleware/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ type LabelsQueryRequest interface {
// like `up{job="prometheus"}` and `{__name__="up, job="prometheus"}`, or other idiosyncrasies.
GetLabelMatcherSets() []string
// GetLimit returns the limit of the number of items in the response.
GetLimit() int64
GetLimit() uint64
// AddSpanTags writes information about this request to an OpenTracing span
AddSpanTags(opentracing.Span)
}
Expand Down Expand Up @@ -313,7 +313,7 @@ func (prometheusCodec) DecodeLabelsQueryRequest(_ context.Context, r *http.Reque

labelMatcherSets := reqValues["match[]"]

limit, err := strconv.ParseInt(reqValues.Get("limit"), 10, 64)
limit, err := strconv.ParseUint(reqValues.Get("limit"), 10, 64)
if reqValues.Has("limit") && err != nil {
return nil, apierror.New(apierror.TypeBadData, "limit parameter: "+err.Error())
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/frontend/querymiddleware/labels_query_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (g DefaultCacheKeyGenerator) LabelValues(r *http.Request) (*GenericQueryCac
}, nil
}

func generateLabelsQueryRequestCacheKey(startTime, endTime int64, labelName string, matcherSets [][]*labels.Matcher, limit int64) string {
func generateLabelsQueryRequestCacheKey(startTime, endTime int64, labelName string, matcherSets [][]*labels.Matcher, limit uint64) string {
var (
twoHoursMillis = (2 * time.Hour).Milliseconds()
b = strings.Builder{}
Expand Down
2 changes: 1 addition & 1 deletion pkg/frontend/querymiddleware/labels_query_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func TestGenerateLabelsQueryRequestCacheKey(t *testing.T) {
labelName string
matcherSets [][]*labels.Matcher
expectedCacheKey string
limit int64
limit uint64
}{
"start and end time are aligned to 2h boundaries": {
startTime: mustParseTime("2023-07-05T00:00:00Z"),
Expand Down
42 changes: 21 additions & 21 deletions pkg/frontend/querymiddleware/model.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pkg/frontend/querymiddleware/model.proto
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ message PrometheusLabelNamesQueryRequest {
int64 id = 5;

// Limit the number of label names returned.
int64 limit = 6;
uint64 limit = 6;
}

message PrometheusLabelValuesQueryRequest {
Expand All @@ -103,7 +103,7 @@ message PrometheusLabelValuesQueryRequest {
int64 id = 6;

// Limit the number of label values returned.
int64 limit = 7;
uint64 limit = 7;
}

message PrometheusResponseHeader {
Expand Down

0 comments on commit 81b3329

Please sign in to comment.