Skip to content

Commit

Permalink
Fix name.
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>
  • Loading branch information
pstibrany committed Jun 16, 2021
1 parent 640e66a commit 2c62abb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
24 changes: 12 additions & 12 deletions pkg/querier/error_translate_queryable.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/cortexproject/cortex/pkg/util/validation"
)

// TranslateToPromqlApiError converts error to one of promql.Errors for consumption in PromQL API.
// TranslateToPromqlAPIError converts error to one of promql.Errors for consumption in PromQL API.
// PromQL API only recognizes few errors, and converts everything else to HTTP status code 422.
//
// Specifically, it supports:
Expand All @@ -28,7 +28,7 @@ import (
// Details:
// - vendor/github.com/prometheus/prometheus/web/api/v1/api.go, respondError function only accepts *apiError types.
// - translation of error to *apiError happens in vendor/github.com/prometheus/prometheus/web/api/v1/api.go, returnAPIError method.
func TranslateToPromqlApiError(err error) error {
func TranslateToPromqlAPIError(err error) error {
if err == nil {
return err
}
Expand Down Expand Up @@ -79,12 +79,12 @@ type errorTranslateQueryable struct {

func (e errorTranslateQueryable) Querier(ctx context.Context, mint, maxt int64) (storage.Querier, error) {
q, err := e.q.Querier(ctx, mint, maxt)
return errorTranslateQuerier{q: q}, TranslateToPromqlApiError(err)
return errorTranslateQuerier{q: q}, TranslateToPromqlAPIError(err)
}

func (e errorTranslateQueryable) ChunkQuerier(ctx context.Context, mint, maxt int64) (storage.ChunkQuerier, error) {
q, err := e.q.ChunkQuerier(ctx, mint, maxt)
return errorTranslateChunkQuerier{q: q}, TranslateToPromqlApiError(err)
return errorTranslateChunkQuerier{q: q}, TranslateToPromqlAPIError(err)
}

type errorTranslateQuerier struct {
Expand All @@ -93,16 +93,16 @@ type errorTranslateQuerier struct {

func (e errorTranslateQuerier) LabelValues(name string, matchers ...*labels.Matcher) ([]string, storage.Warnings, error) {
values, warnings, err := e.q.LabelValues(name, matchers...)
return values, warnings, TranslateToPromqlApiError(err)
return values, warnings, TranslateToPromqlAPIError(err)
}

func (e errorTranslateQuerier) LabelNames() ([]string, storage.Warnings, error) {
values, warnings, err := e.q.LabelNames()
return values, warnings, TranslateToPromqlApiError(err)
return values, warnings, TranslateToPromqlAPIError(err)
}

func (e errorTranslateQuerier) Close() error {
return TranslateToPromqlApiError(e.q.Close())
return TranslateToPromqlAPIError(e.q.Close())
}

func (e errorTranslateQuerier) Select(sortSeries bool, hints *storage.SelectHints, matchers ...*labels.Matcher) storage.SeriesSet {
Expand All @@ -116,16 +116,16 @@ type errorTranslateChunkQuerier struct {

func (e errorTranslateChunkQuerier) LabelValues(name string, matchers ...*labels.Matcher) ([]string, storage.Warnings, error) {
values, warnings, err := e.q.LabelValues(name, matchers...)
return values, warnings, TranslateToPromqlApiError(err)
return values, warnings, TranslateToPromqlAPIError(err)
}

func (e errorTranslateChunkQuerier) LabelNames() ([]string, storage.Warnings, error) {
values, warnings, err := e.q.LabelNames()
return values, warnings, TranslateToPromqlApiError(err)
return values, warnings, TranslateToPromqlAPIError(err)
}

func (e errorTranslateChunkQuerier) Close() error {
return TranslateToPromqlApiError(e.q.Close())
return TranslateToPromqlAPIError(e.q.Close())
}

func (e errorTranslateChunkQuerier) Select(sortSeries bool, hints *storage.SelectHints, matchers ...*labels.Matcher) storage.ChunkSeriesSet {
Expand All @@ -146,7 +146,7 @@ func (e errorTranslateSeriesSet) At() storage.Series {
}

func (e errorTranslateSeriesSet) Err() error {
return TranslateToPromqlApiError(e.s.Err())
return TranslateToPromqlAPIError(e.s.Err())
}

func (e errorTranslateSeriesSet) Warnings() storage.Warnings {
Expand All @@ -166,7 +166,7 @@ func (e errorTranslateChunkSeriesSet) At() storage.ChunkSeries {
}

func (e errorTranslateChunkSeriesSet) Err() error {
return TranslateToPromqlApiError(e.s.Err())
return TranslateToPromqlAPIError(e.s.Err())
}

func (e errorTranslateChunkSeriesSet) Warnings() storage.Warnings {
Expand Down
2 changes: 1 addition & 1 deletion pkg/ruler/compat.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func metricsQueryFunc(qf rules.QueryFunc, queries, failedQueries prometheus.Coun
//
// All errors will still be counted towards "evaluation failures" metrics and logged by Prometheus Ruler,
// but we only want internal errors here.
if _, ok := querier.TranslateToPromqlApiError(err).(promql.ErrStorage); ok {
if _, ok := querier.TranslateToPromqlAPIError(err).(promql.ErrStorage); ok {
failedQueries.Inc()
}
return result, err
Expand Down

0 comments on commit 2c62abb

Please sign in to comment.