Skip to content

Commit 25234e8

Browse files
authored
fix(detected_labels): Add matchers to get labels from store" (#14012)
1 parent ab1caea commit 25234e8

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

pkg/querier/querier.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,7 @@ func (q *SingleTenantQuerier) DetectedLabels(ctx context.Context, req *logproto.
963963
var err error
964964
start := model.TimeFromUnixNano(storeQueryInterval.start.UnixNano())
965965
end := model.TimeFromUnixNano(storeQueryInterval.end.UnixNano())
966-
storeLabels, err := q.store.LabelNamesForMetricName(ctx, userID, start, end, "logs")
966+
storeLabels, err := q.store.LabelNamesForMetricName(ctx, userID, start, end, "logs", matchers...)
967967
for _, label := range storeLabels {
968968
values, err := q.store.LabelValuesForMetricName(ctx, userID, start, end, "logs", label, matchers...)
969969
if err != nil {

pkg/querier/querier_mock_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,8 @@ func (s *storeMock) LabelValuesForMetricName(ctx context.Context, userID string,
356356
return args.Get(0).([]string), args.Error(1)
357357
}
358358

359-
func (s *storeMock) LabelNamesForMetricName(ctx context.Context, userID string, from, through model.Time, metricName string, _ ...*labels.Matcher) ([]string, error) {
360-
args := s.Called(ctx, userID, from, through, metricName)
359+
func (s *storeMock) LabelNamesForMetricName(ctx context.Context, userID string, from, through model.Time, metricName string, m ...*labels.Matcher) ([]string, error) {
360+
args := s.Called(ctx, userID, from, through, metricName, m)
361361
return args.Get(0).([]string), args.Error(1)
362362
}
363363

pkg/querier/querier_test.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,7 @@ func setupIngesterQuerierMocks(conf Config, limits *validation.Overrides) (*quer
11641164
store.On("SelectLogs", mock.Anything, mock.Anything).Return(mockStreamIterator(0, 1), nil)
11651165
store.On("SelectSamples", mock.Anything, mock.Anything).Return(mockSampleIterator(querySampleClient), nil)
11661166
store.On("LabelValuesForMetricName", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return([]string{"1", "2", "3"}, nil)
1167-
store.On("LabelNamesForMetricName", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return([]string{"foo"}, nil)
1167+
store.On("LabelNamesForMetricName", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return([]string{"foo"}, nil)
11681168
store.On("SelectSeries", mock.Anything, mock.Anything).Return([]logproto.SeriesIdentifier{
11691169
{Labels: []logproto.SeriesIdentifier_LabelsEntry{{Key: "foo", Value: "1"}}},
11701170
}, nil)
@@ -1411,7 +1411,7 @@ func TestQuerier_DetectedLabels(t *testing.T) {
14111411

14121412
ingesterClient.On("GetDetectedLabels", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
14131413
Return(&ingesterResponse, nil)
1414-
storeClient.On("LabelNamesForMetricName", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
1414+
storeClient.On("LabelNamesForMetricName", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
14151415
Return([]string{"storeLabel"}, nil).
14161416
On("LabelValuesForMetricName", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, "storeLabel", mock.Anything).
14171417
Return([]string{"val1", "val2"}, nil)
@@ -1452,7 +1452,7 @@ func TestQuerier_DetectedLabels(t *testing.T) {
14521452

14531453
ingesterClient.On("GetDetectedLabels", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
14541454
Return(&ingesterResponse, nil)
1455-
storeClient.On("LabelNamesForMetricName", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
1455+
storeClient.On("LabelNamesForMetricName", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
14561456
Return([]string{"storeLabel", "commonLabel"}, nil).
14571457
On("LabelValuesForMetricName", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, "storeLabel", mock.Anything).
14581458
Return([]string{"val1", "val2"}, nil).
@@ -1490,7 +1490,7 @@ func TestQuerier_DetectedLabels(t *testing.T) {
14901490

14911491
ingesterClient.On("GetDetectedLabels", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
14921492
Return(&logproto.LabelToValuesResponse{}, nil)
1493-
storeClient.On("LabelNamesForMetricName", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
1493+
storeClient.On("LabelNamesForMetricName", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
14941494
Return([]string{"storeLabel1", "storeLabel2"}, nil).
14951495
On("LabelValuesForMetricName", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, "storeLabel1", mock.Anything).
14961496
Return([]string{"val1", "val2"}, nil).
@@ -1524,7 +1524,7 @@ func TestQuerier_DetectedLabels(t *testing.T) {
15241524

15251525
ingesterClient.On("GetDetectedLabels", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
15261526
Return(&logproto.LabelToValuesResponse{}, nil)
1527-
storeClient.On("LabelNamesForMetricName", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
1527+
storeClient.On("LabelNamesForMetricName", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
15281528
Return([]string{"storeLabel1", "pod"}, nil).
15291529
On("LabelValuesForMetricName", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, "storeLabel1", mock.Anything).
15301530
Return([]string{"val1", "val2"}, nil).
@@ -1563,7 +1563,7 @@ func TestQuerier_DetectedLabels(t *testing.T) {
15631563

15641564
ingesterClient.On("GetDetectedLabels", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
15651565
Return(&ingesterResponse, nil)
1566-
storeClient.On("LabelNamesForMetricName", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
1566+
storeClient.On("LabelNamesForMetricName", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
15671567
Return([]string{}, nil)
15681568

15691569
querier, err := newQuerier(
@@ -1599,7 +1599,7 @@ func TestQuerier_DetectedLabels(t *testing.T) {
15991599

16001600
ingesterClient.On("GetDetectedLabels", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
16011601
Return(&ingesterResponse, nil)
1602-
storeClient.On("LabelNamesForMetricName", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
1602+
storeClient.On("LabelNamesForMetricName", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
16031603
Return([]string{}, nil)
16041604

16051605
querier, err := newQuerier(
@@ -1630,7 +1630,7 @@ func TestQuerier_DetectedLabels(t *testing.T) {
16301630

16311631
ingesterClient.On("GetDetectedLabels", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
16321632
Return(&ingesterResponse, nil)
1633-
storeClient.On("LabelNamesForMetricName", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
1633+
storeClient.On("LabelNamesForMetricName", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
16341634
Return([]string{}, nil)
16351635
request := logproto.DetectedLabelsRequest{
16361636
Start: now,
@@ -1665,7 +1665,7 @@ func TestQuerier_DetectedLabels(t *testing.T) {
16651665

16661666
ingesterClient.On("GetDetectedLabels", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
16671667
Return(nil, nil)
1668-
storeClient.On("LabelNamesForMetricName", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
1668+
storeClient.On("LabelNamesForMetricName", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).
16691669
Return([]string{}, nil)
16701670
request := logproto.DetectedLabelsRequest{
16711671
Start: now,

0 commit comments

Comments
 (0)