Skip to content

Commit

Permalink
add context cancellation checks on GetSeries
Browse files Browse the repository at this point in the history
Signed-off-by: Erlan Zholdubai uulu <erlanz@amazon.com>
  • Loading branch information
erlan-z committed Mar 26, 2024
1 parent 0cbc21f commit 78a8848
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
7 changes: 1 addition & 6 deletions pkg/querier/distributor_queryable.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,7 @@ func (q *distributorQuerier) Select(ctx context.Context, sortSeries bool, sp *st
if err != nil {
return storage.ErrSeriesSet(err)
}
seriesSet, err := series.MetricsToSeriesSet(ctx, sortSeries, ms)
if err != nil {
return storage.ErrSeriesSet(err)
}

return seriesSet
return series.MetricsToSeriesSet(ctx, sortSeries, ms)
}

return q.streamingSelect(ctx, sortSeries, minT, maxT, matchers)
Expand Down
6 changes: 3 additions & 3 deletions pkg/querier/series/series_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,18 +168,18 @@ func MatrixToSeriesSet(sortSeries bool, m model.Matrix) storage.SeriesSet {
}

// MetricsToSeriesSet creates a storage.SeriesSet from a []metric.Metric
func MetricsToSeriesSet(ctx context.Context, sortSeries bool, ms []metric.Metric) (storage.SeriesSet, error) {
func MetricsToSeriesSet(ctx context.Context, sortSeries bool, ms []metric.Metric) storage.SeriesSet {
series := make([]storage.Series, 0, len(ms))
for _, m := range ms {
if ctx.Err() != nil {
return nil, ctx.Err()
return storage.ErrSeriesSet(ctx.Err())
}
series = append(series, &ConcreteSeries{
labels: metricToLabels(m.Metric),
samples: nil,
})
}
return NewConcreteSeriesSet(sortSeries, series), nil
return NewConcreteSeriesSet(sortSeries, series)
}

func metricToLabels(m model.Metric) labels.Labels {
Expand Down

0 comments on commit 78a8848

Please sign in to comment.