Skip to content
This repository was archived by the owner on Aug 23, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1649 from grafana/mix_meta_tags_and_normal_tags_i…
Browse files Browse the repository at this point in the history
…n_autocomplete

auto complete should not ignore meta tags if they are also metric tags
  • Loading branch information
replay authored Jan 29, 2020
2 parents d37ddf3 + 7bd481e commit 9e02687
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
11 changes: 1 addition & 10 deletions idx/memory/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -1451,20 +1451,11 @@ func (m *UnpartitionedMemoryIdx) FindTagValuesWithQuery(orgId uint32, tag, prefi
m.RLock()
defer m.RUnlock()

tags, ok := m.tags[orgId]
if !ok {
return nil
}

// check whether the tag of which we're looking up values is a metric tag
// if so we can skip the meta tag enrichment
_, isMetricTag := tags[tag]

resMap := make(map[string]struct{})

var enricher *metaTagEnricher
var mtr *metaTagRecords
if MetaTagSupport && !isMetricTag {
if MetaTagSupport {
mtr, _, enricher = m.getMetaTagDataStructures(orgId, false)
if enricher != nil && enricher.countMetricsWithMetaTags() == 0 {
// if the enricher is empty we set it back to nil so it doesn't even get called
Expand Down
8 changes: 4 additions & 4 deletions idx/memory/memory_find_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,7 @@ func testAutoCompleteTagValuesWithQueryWithMetaTagSupport(t *testing.T) {
prefix: "",
expr: []string{"host=~.+"},
limit: 100,
expRes: []string{"read", "write"},
expRes: []string{"none", "read", "write"},
}, {
tag: "direction",
prefix: "wr",
Expand All @@ -1131,13 +1131,13 @@ func testAutoCompleteTagValuesWithQueryWithMetaTagSupport(t *testing.T) {
prefix: "no",
expr: []string{"host=~.+"},
limit: 100,
expRes: []string{},
expRes: []string{"none"},
}, {
tag: "direction",
prefix: "",
expr: []string{"host=~.+"},
limit: 1,
expRes: []string{"read"},
limit: 2,
expRes: []string{"none", "read"},
}, {
tag: "all",
prefix: "",
Expand Down

0 comments on commit 9e02687

Please sign in to comment.