Skip to content

Commit

Permalink
chore: clean up linting
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorwhitney committed May 31, 2024
1 parent abb31a8 commit 87f7282
Show file tree
Hide file tree
Showing 16 changed files with 135 additions and 138 deletions.
1 change: 0 additions & 1 deletion pkg/loghttp/patterns.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,3 @@ func ParsePatternsQuery(r *http.Request) (*logproto.QueryPatternsRequest, error)

return req, nil
}

2 changes: 1 addition & 1 deletion pkg/logproto/compat.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func FromMetricsToLabelAdapters(metric model.Metric) []LabelAdapter {
}

func FromMetricsToLabels(metric model.Metric) labels.Labels {
return FromLabelAdaptersToLabels(FromMetricsToLabelAdapters(metric))
return FromLabelAdaptersToLabels(FromMetricsToLabelAdapters(metric))
}

type byLabel []LabelAdapter
Expand Down
76 changes: 38 additions & 38 deletions pkg/logproto/pattern.pb.go

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

3 changes: 1 addition & 2 deletions pkg/logproto/pattern.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ package logproto;
import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";
import "pkg/logproto/logproto.proto";
import "pkg/push/push.proto";
import "pkg/logqlmodel/stats/stats.proto";
import "pkg/push/push.proto";

option go_package = "github.com/grafana/loki/v3/pkg/logproto";

Expand Down Expand Up @@ -59,7 +59,6 @@ message QuerySamplesRequest {
int64 step = 4;
}


message QuerySamplesResponse {
repeated Series series = 1 [
(gogoproto.customtype) = "Series",
Expand Down
2 changes: 1 addition & 1 deletion pkg/pattern/drain/chunk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestAdd(t *testing.T) {
cks.Add(model.TimeFromUnixNano(time.Hour.Nanoseconds()) + chunk.TimeResolution + 1)
require.Equal(t, 2, len(cks))
require.Equal(t, 1, len(cks[1].Samples))
cks.Add(model.TimeFromUnixNano(time.Hour.Nanoseconds()) - TimeResolution)
cks.Add(model.TimeFromUnixNano(time.Hour.Nanoseconds()) - chunk.TimeResolution)
require.Equal(t, 2, len(cks))
require.Equalf(t, 1, len(cks[1].Samples), "Older samples should not be added if they arrive out of order")
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/pattern/ingester_querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ func (q *IngesterQuerier) Samples(
}

var selector syntax.LogSelectorExpr
switch expr.(type) {
switch e := expr.(type) {
case *syntax.VectorAggregationExpr:
selector, err = expr.(*syntax.VectorAggregationExpr).Selector()
selector, err = e.Selector()
case *syntax.RangeAggregationExpr:
selector, err = expr.(*syntax.RangeAggregationExpr).Selector()
selector, err = e.Selector()
default:
return nil, ErrParseQuery
}
Expand Down
40 changes: 20 additions & 20 deletions pkg/pattern/ingester_querier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,19 +144,19 @@ func (f *fakeRingClient) Pool() *ring_client.Pool {
panic("not implemented")
}

func (f *fakeRingClient) StartAsync(ctx context.Context) error {
func (f *fakeRingClient) StartAsync(_ context.Context) error {
panic("not implemented")
}

func (f *fakeRingClient) AwaitRunning(ctx context.Context) error {
func (f *fakeRingClient) AwaitRunning(_ context.Context) error {
panic("not implemented")
}

func (f *fakeRingClient) StopAsync() {
panic("not implemented")
}

func (f *fakeRingClient) AwaitTerminated(ctx context.Context) error {
func (f *fakeRingClient) AwaitTerminated(_ context.Context) error {
panic("not implemented")
}

Expand All @@ -168,7 +168,7 @@ func (f *fakeRingClient) State() services.State {
panic("not implemented")
}

func (f *fakeRingClient) AddListener(listener services.Listener) {
func (f *fakeRingClient) AddListener(_ services.Listener) {
panic("not implemented")
}

Expand All @@ -179,20 +179,20 @@ func (f *fakeRingClient) Ring() ring.ReadRing {
type fakeRing struct{}

func (f *fakeRing) Get(
key uint32,
op ring.Operation,
bufDescs []ring.InstanceDesc,
bufHosts []string,
bufZones []string,
_ uint32,
_ ring.Operation,
_ []ring.InstanceDesc,
_ []string,
_ []string,
) (ring.ReplicationSet, error) {
panic("not implemented")
}

func (f *fakeRing) GetAllHealthy(op ring.Operation) (ring.ReplicationSet, error) {
func (f *fakeRing) GetAllHealthy(_ ring.Operation) (ring.ReplicationSet, error) {
panic("not implemented")
}

func (f *fakeRing) GetReplicationSetForOperation(op ring.Operation) (ring.ReplicationSet, error) {
func (f *fakeRing) GetReplicationSetForOperation(_ ring.Operation) (ring.ReplicationSet, error) {
return ring.ReplicationSet{}, nil
}

Expand All @@ -204,31 +204,31 @@ func (f *fakeRing) InstancesCount() int {
panic("not implemented")
}

func (f *fakeRing) ShuffleShard(identifier string, size int) ring.ReadRing {
func (f *fakeRing) ShuffleShard(_ string, _ int) ring.ReadRing {
panic("not implemented")
}

func (f *fakeRing) GetInstanceState(instanceID string) (ring.InstanceState, error) {
func (f *fakeRing) GetInstanceState(_ string) (ring.InstanceState, error) {
panic("not implemented")
}

func (f *fakeRing) ShuffleShardWithLookback(
identifier string,
size int,
lookbackPeriod time.Duration,
now time.Time,
_ string,
_ int,
_ time.Duration,
_ time.Time,
) ring.ReadRing {
panic("not implemented")
}

func (f *fakeRing) HasInstance(instanceID string) bool {
func (f *fakeRing) HasInstance(_ string) bool {
panic("not implemented")
}

func (f *fakeRing) CleanupShuffleShardCache(identifier string) {
func (f *fakeRing) CleanupShuffleShardCache(_ string) {
panic("not implemented")
}

func (f *fakeRing) GetTokenRangesForInstance(instanceID string) (ring.TokenRanges, error) {
func (f *fakeRing) GetTokenRangesForInstance(_ string) (ring.TokenRanges, error) {
panic("not implemented")
}
5 changes: 4 additions & 1 deletion pkg/pattern/ingester_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func TestInstancePushQuery(t *testing.T) {
},
},
})
require.NoError(t, err)

err = inst.Push(context.Background(), &push.PushRequest{
Streams: []push.Stream{
Expand All @@ -58,6 +59,8 @@ func TestInstancePushQuery(t *testing.T) {
},
},
})
require.NoError(t, err)

for i := 0; i <= 30; i++ {
err = inst.Push(context.Background(), &push.PushRequest{
Streams: []push.Stream{
Expand All @@ -74,7 +77,7 @@ func TestInstancePushQuery(t *testing.T) {
})
require.NoError(t, err)
}
require.NoError(t, err)

it, err := inst.Iterator(context.Background(), &logproto.QueryPatternsRequest{
Query: "{test=\"test\"}",
Start: time.Unix(0, 0),
Expand Down
4 changes: 2 additions & 2 deletions pkg/pattern/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (i *instance) Push(ctx context.Context, req *logproto.PushRequest) error {
s, _, err := i.streams.LoadOrStoreNew(reqStream.Labels,
func() (*stream, error) {
// add stream
return i.createStream(ctx, reqStream, i.aggregationCfg.Enabled)
return i.createStream(ctx, reqStream)
}, nil)
if err != nil {
appendErr.Add(err)
Expand Down Expand Up @@ -182,7 +182,7 @@ outer:
return nil
}

func (i *instance) createStream(_ context.Context, pushReqStream logproto.Stream, aggregateMetrics bool) (*stream, error) {
func (i *instance) createStream(_ context.Context, pushReqStream logproto.Stream) (*stream, error) {
labels, err := syntax.ParseLabels(pushReqStream.Labels)
if err != nil {
return nil, httpgrpc.Errorf(http.StatusBadRequest, err.Error())
Expand Down
7 changes: 4 additions & 3 deletions pkg/pattern/instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import (
"time"

"github.com/go-kit/log"
"github.com/grafana/loki/pkg/push"
"github.com/grafana/loki/v3/pkg/logproto"
"github.com/grafana/loki/v3/pkg/logql/syntax"
"github.com/grafana/loki/v3/pkg/pattern/metric"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/grafana/loki/pkg/push"
)

func TestInstance_QuerySample(t *testing.T) {
Expand Down Expand Up @@ -41,8 +42,7 @@ func TestInstance_QuerySample(t *testing.T) {

lastTsMilli := (then + oneMin + thirtySeconds) // 0 + 60000 + 30000 = 90000

// TODO(twhitney): Add a few more pushes to this or another test
instance.Push(ctx, &logproto.PushRequest{
err = instance.Push(ctx, &logproto.PushRequest{
Streams: []push.Stream{
{
Labels: labels.String(),
Expand All @@ -68,6 +68,7 @@ func TestInstance_QuerySample(t *testing.T) {
},
},
})
require.NoError(t, err)

// 5 min query range
// 1 min step
Expand Down
2 changes: 1 addition & 1 deletion pkg/pattern/iter/batch.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func ReadMetricsBatch(it iter.SampleIterator, batchSize int) (*logproto.QuerySam
Samples: []logproto.Sample{},
StreamHash: hash,
}
series[hash] = s
series[hash] = s
}

s.Samples = append(s.Samples, it.Sample())
Expand Down
Loading

0 comments on commit 87f7282

Please sign in to comment.