Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
Signed-off-by: SungJin1212 <[email protected]>
  • Loading branch information
SungJin1212 committed Jan 14, 2025
1 parent 7ff1801 commit a904f7b
Show file tree
Hide file tree
Showing 24 changed files with 49 additions and 15 deletions.
5 changes: 3 additions & 2 deletions execution/aggregate/accumulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ package aggregate

import (
"context"
"errors"
"math"

"github.com/efficientgo/core/errors"
"github.com/prometheus/prometheus/model/histogram"
"github.com/prometheus/prometheus/promql/parser/posrange"
"github.com/prometheus/prometheus/util/annotations"
"github.com/thanos-io/promql-engine/execution/warnings"
"gonum.org/v1/gonum/floats"

"github.com/thanos-io/promql-engine/execution/warnings"
)

type ValueType int
Expand Down
1 change: 1 addition & 0 deletions execution/aggregate/count_values.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"time"

"github.com/prometheus/prometheus/model/labels"

"github.com/thanos-io/promql-engine/execution/model"
"github.com/thanos-io/promql-engine/query"
)
Expand Down
1 change: 1 addition & 0 deletions execution/aggregate/hashaggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func NewHashAggregate(
// https://github.com/prometheus/prometheus/blob/8ed39fdab1ead382a354e45ded999eb3610f8d5f/model/labels/labels.go#L162-L181
slices.Sort(labels)
a := &aggregate{

next: next,
paramOp: paramOp,
params: make([]float64, opts.StepsBatch),
Expand Down
2 changes: 1 addition & 1 deletion execution/aggregate/khashaggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import (
"github.com/efficientgo/core/errors"
"github.com/prometheus/prometheus/promql/parser/posrange"
"github.com/prometheus/prometheus/util/annotations"
"github.com/thanos-io/promql-engine/execution/warnings"
"golang.org/x/exp/slices"

"github.com/prometheus/prometheus/model/labels"
"github.com/prometheus/prometheus/promql/parser"

"github.com/thanos-io/promql-engine/execution/model"
"github.com/thanos-io/promql-engine/execution/warnings"
"github.com/thanos-io/promql-engine/query"
)

Expand Down
1 change: 0 additions & 1 deletion execution/aggregate/vector_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
)

type vectorTable struct {
ctx context.Context
ts int64
accumulator vectorAccumulator
}
Expand Down
2 changes: 1 addition & 1 deletion execution/binary/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (
"github.com/prometheus/prometheus/promql/parser"
"github.com/prometheus/prometheus/promql/parser/posrange"
"github.com/prometheus/prometheus/util/annotations"
"github.com/thanos-io/promql-engine/execution/warnings"

"github.com/thanos-io/promql-engine/execution/parse"
"github.com/thanos-io/promql-engine/execution/warnings"
)

type binOpSide string
Expand Down
6 changes: 3 additions & 3 deletions execution/binary/vector.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/efficientgo/core/errors"
"github.com/prometheus/prometheus/promql/parser/posrange"
"github.com/prometheus/prometheus/util/annotations"
"github.com/thanos-io/promql-engine/execution/warnings"
"github.com/zhangyunhao116/umap"
"golang.org/x/exp/slices"

Expand All @@ -23,6 +22,7 @@ import (
"github.com/prometheus/prometheus/promql/parser"

"github.com/thanos-io/promql-engine/execution/model"
"github.com/thanos-io/promql-engine/execution/warnings"
"github.com/thanos-io/promql-engine/query"
)

Expand Down Expand Up @@ -402,7 +402,7 @@ func (o *vectorOperator) execBinaryArithmetic(ctx context.Context, lhs, rhs mode
var err error

if jp.histogramVal != nil {
_, h, keep, err = o.computeBinaryPairing(ctx, hcs.Samples[i], 0, nil, jp.histogramVal)
_, h, _, err = o.computeBinaryPairing(ctx, hcs.Samples[i], 0, nil, jp.histogramVal)
if err != nil {
if errors.Is(err, annotations.PromQLInfo) || errors.Is(err, annotations.PromQLWarning) {
// just continue when the errors are info and warn
Expand Down Expand Up @@ -689,5 +689,5 @@ func vectorElemBinop(ctx context.Context, op parser.ItemType, lhs, rhs float64,
}
}
}
panic(fmt.Errorf("operator %q not allowed for operations between Vectors", op))
panic(errors.Newf("operator %q not allowed for operations between Vectors", op))
}
1 change: 1 addition & 0 deletions execution/exchange/coalesce.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/efficientgo/core/errors"
"github.com/prometheus/prometheus/model/labels"

"github.com/thanos-io/promql-engine/execution/model"
"github.com/thanos-io/promql-engine/query"
)
Expand Down
3 changes: 2 additions & 1 deletion execution/exchange/concurrent.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import (
"sync"
"time"

"github.com/prometheus/prometheus/model/labels"
"github.com/thanos-io/promql-engine/execution/model"
"github.com/thanos-io/promql-engine/query"

"github.com/prometheus/prometheus/model/labels"
)

type maybeStepVector struct {
Expand Down
1 change: 1 addition & 0 deletions execution/exchange/dedup.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/cespare/xxhash/v2"
"github.com/prometheus/prometheus/model/histogram"
"github.com/prometheus/prometheus/model/labels"

"github.com/thanos-io/promql-engine/execution/model"
"github.com/thanos-io/promql-engine/query"
)
Expand Down
1 change: 1 addition & 0 deletions execution/exchange/duplicate_label.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"time"

"github.com/prometheus/prometheus/model/labels"

"github.com/thanos-io/promql-engine/execution/model"
"github.com/thanos-io/promql-engine/extlabels"
"github.com/thanos-io/promql-engine/query"
Expand Down
1 change: 1 addition & 0 deletions execution/function/absent.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"time"

"github.com/prometheus/prometheus/model/labels"

"github.com/thanos-io/promql-engine/execution/model"
"github.com/thanos-io/promql-engine/logicalplan"
"github.com/thanos-io/promql-engine/query"
Expand Down
1 change: 1 addition & 0 deletions execution/function/noarg.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"time"

"github.com/prometheus/prometheus/model/labels"

"github.com/thanos-io/promql-engine/execution/model"
"github.com/thanos-io/promql-engine/logicalplan"
)
Expand Down
2 changes: 1 addition & 1 deletion execution/function/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/efficientgo/core/errors"
"github.com/prometheus/prometheus/model/labels"
"github.com/prometheus/prometheus/promql/parser"

"github.com/thanos-io/promql-engine/execution/model"
"github.com/thanos-io/promql-engine/execution/parse"
"github.com/thanos-io/promql-engine/extlabels"
Expand Down Expand Up @@ -240,7 +241,6 @@ func (o *functionOperator) loadSeries(ctx context.Context) error {
err = loadErr
return
}

o.series = make([]labels.Labels, len(series))

b := labels.ScratchBuilder{}
Expand Down
3 changes: 1 addition & 2 deletions execution/function/relabel.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/efficientgo/core/errors"
prommodel "github.com/prometheus/common/model"
"github.com/prometheus/prometheus/model/labels"

"github.com/thanos-io/promql-engine/execution/model"
"github.com/thanos-io/promql-engine/logicalplan"
"github.com/thanos-io/promql-engine/query"
Expand Down Expand Up @@ -74,7 +75,6 @@ func (o *relabelOperator) loadSeries(ctx context.Context) (err error) {
if err != nil {
return err
}

o.series = make([]labels.Labels, len(series))

switch o.funcExpr.Func.Name {
Expand All @@ -85,7 +85,6 @@ func (o *relabelOperator) loadSeries(ctx context.Context) (err error) {
default:
err = errors.Newf("invalid function name for relabel operator: %s", o.funcExpr.Func.Name)
}

return err
}

Expand Down
1 change: 1 addition & 0 deletions execution/function/scalar.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"time"

"github.com/prometheus/prometheus/model/labels"

"github.com/thanos-io/promql-engine/execution/model"
"github.com/thanos-io/promql-engine/query"
)
Expand Down
2 changes: 1 addition & 1 deletion execution/function/timestamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"time"

"github.com/prometheus/prometheus/model/labels"
"github.com/thanos-io/promql-engine/extlabels"

"github.com/thanos-io/promql-engine/execution/model"
"github.com/thanos-io/promql-engine/extlabels"
"github.com/thanos-io/promql-engine/query"
)

Expand Down
1 change: 1 addition & 0 deletions execution/scan/literal_selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"time"

"github.com/prometheus/prometheus/model/labels"

"github.com/thanos-io/promql-engine/execution/model"
"github.com/thanos-io/promql-engine/query"
)
Expand Down
1 change: 1 addition & 0 deletions execution/scan/subquery.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"time"

"github.com/prometheus/prometheus/model/labels"

"github.com/thanos-io/promql-engine/execution/model"
"github.com/thanos-io/promql-engine/extlabels"
"github.com/thanos-io/promql-engine/logicalplan"
Expand Down
1 change: 1 addition & 0 deletions execution/step_invariant/step_invariant.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/efficientgo/core/errors"
"github.com/prometheus/prometheus/model/labels"

"github.com/thanos-io/promql-engine/execution/model"
"github.com/thanos-io/promql-engine/logicalplan"
"github.com/thanos-io/promql-engine/query"
Expand Down
4 changes: 2 additions & 2 deletions ringbuffer/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/efficientgo/core/errors"
"github.com/prometheus/prometheus/model/histogram"
"github.com/prometheus/prometheus/util/annotations"

"github.com/thanos-io/promql-engine/execution/aggregate"
"github.com/thanos-io/promql-engine/execution/parse"
"github.com/thanos-io/promql-engine/execution/warnings"
Expand Down Expand Up @@ -700,8 +701,7 @@ func stdvarOverTime(points []Sample) float64 {
}

func changes(points []Sample) float64 {
var count float64
count = 0
count := 0.

prevSample := points[0]
for _, curSample := range points[1:] {
Expand Down
1 change: 1 addition & 0 deletions ringbuffer/rate.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"slices"

"github.com/prometheus/prometheus/model/histogram"

"github.com/thanos-io/promql-engine/query"
)

Expand Down
21 changes: 21 additions & 0 deletions storage/prometheus/matrix_selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,21 @@ import (
"context"
"fmt"
"math"
"strings"
"sync"
"time"

"github.com/efficientgo/core/errors"
"github.com/prometheus/prometheus/model/histogram"
"github.com/prometheus/prometheus/model/labels"
"github.com/prometheus/prometheus/model/value"
"github.com/prometheus/prometheus/promql/parser/posrange"
"github.com/prometheus/prometheus/tsdb/chunkenc"
"github.com/prometheus/prometheus/util/annotations"

"github.com/thanos-io/promql-engine/execution/model"
"github.com/thanos-io/promql-engine/execution/parse"
"github.com/thanos-io/promql-engine/execution/warnings"
"github.com/thanos-io/promql-engine/extlabels"
"github.com/thanos-io/promql-engine/query"
"github.com/thanos-io/promql-engine/ringbuffer"
Expand Down Expand Up @@ -64,6 +69,7 @@ type matrixSelector struct {

// Lookback delta for extended range functions.
extLookbackDelta int64
inputSeries []SignedSeries
}

var ErrNativeHistogramsNotSupported = errors.New("native histograms are not supported in extended range functions")
Expand Down Expand Up @@ -190,6 +196,19 @@ func (o *matrixSelector) Next(ctx context.Context) ([]model.StepVector, error) {
if h != nil {
vectors[currStep].AppendHistogram(o.vectorPool, scanner.signature, h)
} else if f != nil {
if o.functionName == "rate" || o.functionName == "increase" {
if len(o.inputSeries) > 0 {
metricName := o.inputSeries[0].Labels().Get(labels.MetricName)
if metricName != "" &&
!strings.HasSuffix(metricName, "_total") &&
!strings.HasSuffix(metricName, "_sum") &&
!strings.HasSuffix(metricName, "_count") &&
!strings.HasSuffix(metricName, "_bucket") {
warnings.AddToContext(annotations.NewPossibleNonCounterInfo(metricName, posrange.PositionRange{}), ctx)
}
}
}

vectors[currStep].AppendSample(o.vectorPool, scanner.signature, *f)
}
}
Expand All @@ -213,6 +232,8 @@ func (o *matrixSelector) loadSeries(ctx context.Context) error {
return
}

o.inputSeries = series

o.scanners = make([]matrixScanner, len(series))
o.series = make([]labels.Labels, len(series))
b := labels.ScratchBuilder{}
Expand Down
1 change: 1 addition & 0 deletions storage/prometheus/vector_selector.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"time"

"github.com/efficientgo/core/errors"

"github.com/prometheus/prometheus/model/histogram"
"github.com/prometheus/prometheus/model/labels"
"github.com/prometheus/prometheus/model/value"
Expand Down

0 comments on commit a904f7b

Please sign in to comment.