Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
Signed-off-by: yeya24 <yb532204897@gmail.com>
  • Loading branch information
yeya24 committed Apr 29, 2021
1 parent ad0935e commit 91220c4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
13 changes: 5 additions & 8 deletions pkg/exemplars/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ func (s *Proxy) Exemplars(req *exemplarspb.ExemplarsRequest, srv exemplarspb.Exe

newSelectors := make([][]*labels.Matcher, 0, len(selectors))
for _, matchers := range selectors {
matched, newMatchers, err := matchesExternalLabels(matchers, s.selectorLabels)
if err != nil {
return err
}
matched, newMatchers:= matchesExternalLabels(matchers, s.selectorLabels)
if matched {
newSelectors = append(newSelectors, newMatchers)
}
Expand Down Expand Up @@ -211,9 +208,9 @@ func (stream *exemplarsStream) receive(ctx context.Context) error {

// matchesExternalLabels returns false if given matchers are not matching external labels.
// If true, matchesExternalLabels also returns Prometheus matchers without those matching external labels.
func matchesExternalLabels(ms []*labels.Matcher, externalLabels labels.Labels) (bool, []*labels.Matcher, error) {
func matchesExternalLabels(ms []*labels.Matcher, externalLabels labels.Labels) (bool, []*labels.Matcher) {
if len(externalLabels) == 0 {
return true, ms, nil
return true, ms
}

var newMatchers []*labels.Matcher
Expand All @@ -230,8 +227,8 @@ func matchesExternalLabels(ms []*labels.Matcher, externalLabels labels.Labels) (
if !tm.Matches(extValue) {
// External label does not match. This should not happen - it should be filtered out on query node,
// but let's do that anyway here.
return false, nil, nil
return false, nil
}
}
return true, newMatchers, nil
return true, newMatchers
}
8 changes: 4 additions & 4 deletions pkg/exemplars/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func TestProxy(t *testing.T) {
{
ExemplarsClient: &testExemplarClient{
response: exemplarspb.NewExemplarsResponse(&exemplarspb.ExemplarData{
SeriesLabels: labelpb.ZLabelSet{labelpb.ZLabelsFromPromLabels(labels.FromMap(map[string]string{"foo": "bar"}))},
SeriesLabels: labelpb.ZLabelSet{Labels: labelpb.ZLabelsFromPromLabels(labels.FromMap(map[string]string{"foo": "bar"}))},
Exemplars: []*exemplarspb.Exemplar{{Value: 1}},
}),
},
Expand All @@ -227,7 +227,7 @@ func TestProxy(t *testing.T) {
{
ExemplarsClient: &testExemplarClient{
response: exemplarspb.NewExemplarsResponse(&exemplarspb.ExemplarData{
SeriesLabels: labelpb.ZLabelSet{labelpb.ZLabelsFromPromLabels(labels.FromMap(map[string]string{"foo": "baz"}))},
SeriesLabels: labelpb.ZLabelSet{Labels: labelpb.ZLabelsFromPromLabels(labels.FromMap(map[string]string{"foo": "baz"}))},
Exemplars: []*exemplarspb.Exemplar{{Value: 2}},
}),
},
Expand All @@ -237,11 +237,11 @@ func TestProxy(t *testing.T) {
server: &testExemplarServer{},
wantResponses: []*exemplarspb.ExemplarsResponse{
exemplarspb.NewExemplarsResponse(&exemplarspb.ExemplarData{
SeriesLabels: labelpb.ZLabelSet{labelpb.ZLabelsFromPromLabels(labels.FromMap(map[string]string{"foo": "bar"}))},
SeriesLabels: labelpb.ZLabelSet{Labels: labelpb.ZLabelsFromPromLabels(labels.FromMap(map[string]string{"foo": "bar"}))},
Exemplars: []*exemplarspb.Exemplar{{Value: 1}},
}),
exemplarspb.NewExemplarsResponse(&exemplarspb.ExemplarData{
SeriesLabels: labelpb.ZLabelSet{labelpb.ZLabelsFromPromLabels(labels.FromMap(map[string]string{"foo": "baz"}))},
SeriesLabels: labelpb.ZLabelSet{Labels: labelpb.ZLabelsFromPromLabels(labels.FromMap(map[string]string{"foo": "baz"}))},
Exemplars: []*exemplarspb.Exemplar{{Value: 2}},
}),
},
Expand Down

0 comments on commit 91220c4

Please sign in to comment.