Skip to content

Commit 87f7282

Browse files
committed
chore: clean up linting
1 parent abb31a8 commit 87f7282

16 files changed

+135
-138
lines changed

pkg/loghttp/patterns.go

-1
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,3 @@ func ParsePatternsQuery(r *http.Request) (*logproto.QueryPatternsRequest, error)
3333

3434
return req, nil
3535
}
36-

pkg/logproto/compat.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func FromMetricsToLabelAdapters(metric model.Metric) []LabelAdapter {
8383
}
8484

8585
func FromMetricsToLabels(metric model.Metric) labels.Labels {
86-
return FromLabelAdaptersToLabels(FromMetricsToLabelAdapters(metric))
86+
return FromLabelAdaptersToLabels(FromMetricsToLabelAdapters(metric))
8787
}
8888

8989
type byLabel []LabelAdapter

pkg/logproto/pattern.pb.go

+38-38
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/logproto/pattern.proto

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ package logproto;
55
import "gogoproto/gogo.proto";
66
import "google/protobuf/timestamp.proto";
77
import "pkg/logproto/logproto.proto";
8-
import "pkg/push/push.proto";
98
import "pkg/logqlmodel/stats/stats.proto";
9+
import "pkg/push/push.proto";
1010

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

@@ -59,7 +59,6 @@ message QuerySamplesRequest {
5959
int64 step = 4;
6060
}
6161

62-
6362
message QuerySamplesResponse {
6463
repeated Series series = 1 [
6564
(gogoproto.customtype) = "Series",

pkg/pattern/drain/chunk_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func TestAdd(t *testing.T) {
2222
cks.Add(model.TimeFromUnixNano(time.Hour.Nanoseconds()) + chunk.TimeResolution + 1)
2323
require.Equal(t, 2, len(cks))
2424
require.Equal(t, 1, len(cks[1].Samples))
25-
cks.Add(model.TimeFromUnixNano(time.Hour.Nanoseconds()) - TimeResolution)
25+
cks.Add(model.TimeFromUnixNano(time.Hour.Nanoseconds()) - chunk.TimeResolution)
2626
require.Equal(t, 2, len(cks))
2727
require.Equalf(t, 1, len(cks[1].Samples), "Older samples should not be added if they arrive out of order")
2828
}

pkg/pattern/ingester_querier.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ func (q *IngesterQuerier) Samples(
8181
}
8282

8383
var selector syntax.LogSelectorExpr
84-
switch expr.(type) {
84+
switch e := expr.(type) {
8585
case *syntax.VectorAggregationExpr:
86-
selector, err = expr.(*syntax.VectorAggregationExpr).Selector()
86+
selector, err = e.Selector()
8787
case *syntax.RangeAggregationExpr:
88-
selector, err = expr.(*syntax.RangeAggregationExpr).Selector()
88+
selector, err = e.Selector()
8989
default:
9090
return nil, ErrParseQuery
9191
}

pkg/pattern/ingester_querier_test.go

+20-20
Original file line numberDiff line numberDiff line change
@@ -144,19 +144,19 @@ func (f *fakeRingClient) Pool() *ring_client.Pool {
144144
panic("not implemented")
145145
}
146146

147-
func (f *fakeRingClient) StartAsync(ctx context.Context) error {
147+
func (f *fakeRingClient) StartAsync(_ context.Context) error {
148148
panic("not implemented")
149149
}
150150

151-
func (f *fakeRingClient) AwaitRunning(ctx context.Context) error {
151+
func (f *fakeRingClient) AwaitRunning(_ context.Context) error {
152152
panic("not implemented")
153153
}
154154

155155
func (f *fakeRingClient) StopAsync() {
156156
panic("not implemented")
157157
}
158158

159-
func (f *fakeRingClient) AwaitTerminated(ctx context.Context) error {
159+
func (f *fakeRingClient) AwaitTerminated(_ context.Context) error {
160160
panic("not implemented")
161161
}
162162

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

171-
func (f *fakeRingClient) AddListener(listener services.Listener) {
171+
func (f *fakeRingClient) AddListener(_ services.Listener) {
172172
panic("not implemented")
173173
}
174174

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

181181
func (f *fakeRing) Get(
182-
key uint32,
183-
op ring.Operation,
184-
bufDescs []ring.InstanceDesc,
185-
bufHosts []string,
186-
bufZones []string,
182+
_ uint32,
183+
_ ring.Operation,
184+
_ []ring.InstanceDesc,
185+
_ []string,
186+
_ []string,
187187
) (ring.ReplicationSet, error) {
188188
panic("not implemented")
189189
}
190190

191-
func (f *fakeRing) GetAllHealthy(op ring.Operation) (ring.ReplicationSet, error) {
191+
func (f *fakeRing) GetAllHealthy(_ ring.Operation) (ring.ReplicationSet, error) {
192192
panic("not implemented")
193193
}
194194

195-
func (f *fakeRing) GetReplicationSetForOperation(op ring.Operation) (ring.ReplicationSet, error) {
195+
func (f *fakeRing) GetReplicationSetForOperation(_ ring.Operation) (ring.ReplicationSet, error) {
196196
return ring.ReplicationSet{}, nil
197197
}
198198

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

207-
func (f *fakeRing) ShuffleShard(identifier string, size int) ring.ReadRing {
207+
func (f *fakeRing) ShuffleShard(_ string, _ int) ring.ReadRing {
208208
panic("not implemented")
209209
}
210210

211-
func (f *fakeRing) GetInstanceState(instanceID string) (ring.InstanceState, error) {
211+
func (f *fakeRing) GetInstanceState(_ string) (ring.InstanceState, error) {
212212
panic("not implemented")
213213
}
214214

215215
func (f *fakeRing) ShuffleShardWithLookback(
216-
identifier string,
217-
size int,
218-
lookbackPeriod time.Duration,
219-
now time.Time,
216+
_ string,
217+
_ int,
218+
_ time.Duration,
219+
_ time.Time,
220220
) ring.ReadRing {
221221
panic("not implemented")
222222
}
223223

224-
func (f *fakeRing) HasInstance(instanceID string) bool {
224+
func (f *fakeRing) HasInstance(_ string) bool {
225225
panic("not implemented")
226226
}
227227

228-
func (f *fakeRing) CleanupShuffleShardCache(identifier string) {
228+
func (f *fakeRing) CleanupShuffleShardCache(_ string) {
229229
panic("not implemented")
230230
}
231231

232-
func (f *fakeRing) GetTokenRangesForInstance(instanceID string) (ring.TokenRanges, error) {
232+
func (f *fakeRing) GetTokenRangesForInstance(_ string) (ring.TokenRanges, error) {
233233
panic("not implemented")
234234
}

pkg/pattern/ingester_test.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ func TestInstancePushQuery(t *testing.T) {
4444
},
4545
},
4646
})
47+
require.NoError(t, err)
4748

4849
err = inst.Push(context.Background(), &push.PushRequest{
4950
Streams: []push.Stream{
@@ -58,6 +59,8 @@ func TestInstancePushQuery(t *testing.T) {
5859
},
5960
},
6061
})
62+
require.NoError(t, err)
63+
6164
for i := 0; i <= 30; i++ {
6265
err = inst.Push(context.Background(), &push.PushRequest{
6366
Streams: []push.Stream{
@@ -74,7 +77,7 @@ func TestInstancePushQuery(t *testing.T) {
7477
})
7578
require.NoError(t, err)
7679
}
77-
require.NoError(t, err)
80+
7881
it, err := inst.Iterator(context.Background(), &logproto.QueryPatternsRequest{
7982
Query: "{test=\"test\"}",
8083
Start: time.Unix(0, 0),

pkg/pattern/instance.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func (i *instance) Push(ctx context.Context, req *logproto.PushRequest) error {
6464
s, _, err := i.streams.LoadOrStoreNew(reqStream.Labels,
6565
func() (*stream, error) {
6666
// add stream
67-
return i.createStream(ctx, reqStream, i.aggregationCfg.Enabled)
67+
return i.createStream(ctx, reqStream)
6868
}, nil)
6969
if err != nil {
7070
appendErr.Add(err)
@@ -182,7 +182,7 @@ outer:
182182
return nil
183183
}
184184

185-
func (i *instance) createStream(_ context.Context, pushReqStream logproto.Stream, aggregateMetrics bool) (*stream, error) {
185+
func (i *instance) createStream(_ context.Context, pushReqStream logproto.Stream) (*stream, error) {
186186
labels, err := syntax.ParseLabels(pushReqStream.Labels)
187187
if err != nil {
188188
return nil, httpgrpc.Errorf(http.StatusBadRequest, err.Error())

pkg/pattern/instance_test.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ import (
66
"time"
77

88
"github.com/go-kit/log"
9-
"github.com/grafana/loki/pkg/push"
109
"github.com/grafana/loki/v3/pkg/logproto"
1110
"github.com/grafana/loki/v3/pkg/logql/syntax"
1211
"github.com/grafana/loki/v3/pkg/pattern/metric"
1312
"github.com/prometheus/common/model"
1413
"github.com/stretchr/testify/assert"
1514
"github.com/stretchr/testify/require"
15+
16+
"github.com/grafana/loki/pkg/push"
1617
)
1718

1819
func TestInstance_QuerySample(t *testing.T) {
@@ -41,8 +42,7 @@ func TestInstance_QuerySample(t *testing.T) {
4142

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

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

7273
// 5 min query range
7374
// 1 min step

pkg/pattern/iter/batch.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func ReadMetricsBatch(it iter.SampleIterator, batchSize int) (*logproto.QuerySam
4949
Samples: []logproto.Sample{},
5050
StreamHash: hash,
5151
}
52-
series[hash] = s
52+
series[hash] = s
5353
}
5454

5555
s.Samples = append(s.Samples, it.Sample())

0 commit comments

Comments
 (0)