Skip to content

Commit

Permalink
Fix query split logic for LabelNames, LabelValues and ProfileTypes (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
aleks-p authored Dec 15, 2023
1 parent f2e64d7 commit 178e882
Showing 1 changed file with 30 additions and 12 deletions.
42 changes: 30 additions & 12 deletions pkg/querier/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,7 @@ func (q *Querier) ProfileTypes(ctx context.Context, req *connect.Request[querier

if storeQueries.ingester.shouldQuery {
group.Go(func() error {
ir, err := q.profileTypesFromIngesters(ctx, &ingestv1.ProfileTypesRequest{
Start: req.Msg.Start,
End: req.Msg.End,
})
ir, err := q.profileTypesFromIngesters(ctx, storeQueries.ingester.ProfileTypesRequest(req.Msg))
if err != nil {
return err
}
Expand All @@ -172,10 +169,7 @@ func (q *Querier) ProfileTypes(ctx context.Context, req *connect.Request[querier

if storeQueries.storeGateway.shouldQuery {
group.Go(func() error {
ir, err := q.profileTypesFromStoreGateway(ctx, &ingestv1.ProfileTypesRequest{
Start: req.Msg.Start,
End: req.Msg.End,
})
ir, err := q.profileTypesFromStoreGateway(ctx, storeQueries.storeGateway.ProfileTypesRequest(req.Msg))
if err != nil {
return err
}
Expand Down Expand Up @@ -232,7 +226,7 @@ func (q *Querier) LabelValues(ctx context.Context, req *connect.Request[typesv1.

if storeQueries.ingester.shouldQuery {
group.Go(func() error {
ir, err := q.labelValuesFromIngesters(ctx, req.Msg)
ir, err := q.labelValuesFromIngesters(ctx, storeQueries.ingester.LabelValuesRequest(req.Msg))
if err != nil {
return err
}
Expand All @@ -246,7 +240,7 @@ func (q *Querier) LabelValues(ctx context.Context, req *connect.Request[typesv1.

if storeQueries.storeGateway.shouldQuery {
group.Go(func() error {
ir, err := q.labelValuesFromStoreGateway(ctx, req.Msg)
ir, err := q.labelValuesFromStoreGateway(ctx, storeQueries.storeGateway.LabelValuesRequest(req.Msg))
if err != nil {
return err
}
Expand Down Expand Up @@ -302,7 +296,7 @@ func (q *Querier) LabelNames(ctx context.Context, req *connect.Request[typesv1.L

if storeQueries.ingester.shouldQuery {
group.Go(func() error {
ir, err := q.labelNamesFromIngesters(ctx, req.Msg)
ir, err := q.labelNamesFromIngesters(ctx, storeQueries.ingester.LabelNamesRequest(req.Msg))
if err != nil {
return err
}
Expand All @@ -316,7 +310,7 @@ func (q *Querier) LabelNames(ctx context.Context, req *connect.Request[typesv1.L

if storeQueries.storeGateway.shouldQuery {
group.Go(func() error {
ir, err := q.labelNamesFromStoreGateway(ctx, req.Msg)
ir, err := q.labelNamesFromStoreGateway(ctx, storeQueries.storeGateway.LabelNamesRequest(req.Msg))
if err != nil {
return err
}
Expand Down Expand Up @@ -697,6 +691,30 @@ func (sq storeQuery) SeriesRequest(req *querierv1.SeriesRequest) *ingestv1.Serie
}
}

func (sq storeQuery) LabelNamesRequest(req *typesv1.LabelNamesRequest) *typesv1.LabelNamesRequest {
return &typesv1.LabelNamesRequest{
Matchers: req.Matchers,
Start: int64(sq.start),
End: int64(sq.end),
}
}

func (sq storeQuery) LabelValuesRequest(req *typesv1.LabelValuesRequest) *typesv1.LabelValuesRequest {
return &typesv1.LabelValuesRequest{
Name: req.Name,
Matchers: req.Matchers,
Start: int64(sq.start),
End: int64(sq.end),
}
}

func (sq storeQuery) ProfileTypesRequest(req *querierv1.ProfileTypesRequest) *ingestv1.ProfileTypesRequest {
return &ingestv1.ProfileTypesRequest{
Start: int64(sq.start),
End: int64(sq.end),
}
}

type storeQueries struct {
ingester, storeGateway storeQuery
queryStoreAfter time.Duration
Expand Down

0 comments on commit 178e882

Please sign in to comment.