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

Commit dbe6c96

Browse files
authored
Merge pull request #1512 from grafana/remove_hashing_in_enricher
Remove hashing in enricher
2 parents fc4a9e4 + 5802c36 commit dbe6c96

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

idx/memory/meta_tags.go

+7-13
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"unsafe"
77

88
"github.com/grafana/metrictank/stats"
9-
"github.com/grafana/metrictank/util"
109

1110
"github.com/grafana/metrictank/errors"
1211
"github.com/grafana/metrictank/expr/tagquery"
@@ -175,32 +174,27 @@ func (e *enricher) reportStats() {
175174
enrichmentCacheEntries.Set(e.cache.Len())
176175
}
177176

177+
// enrich takes a metric id, the name string and its tags as strings and evaluates the
178+
// expressions of all meta records to determine which meta tags need to be associated
179+
// with that given metric.
180+
// it is heavily cached, the cache key is org agnostic because the enricher needs to
181+
// be instantiated once per org.
178182
func (e *enricher) enrich(id schema.MKey, name string, tags []string) tagquery.Tags {
179-
h := util.NewFnv64aStringWriter()
180-
h.WriteString(name)
181-
for i := range tags {
182-
h.WriteString(";")
183-
h.WriteString(tags[i])
184-
}
185-
sum := h.Sum64()
186-
187-
cachedRes, ok := e.cache.Get(sum)
183+
cachedRes, ok := e.cache.Get(id.Key)
188184
if ok {
189185
enrichmentCacheHits.Inc()
190186
return cachedRes.(tagquery.Tags)
191187
}
192188
enrichmentCacheMisses.Inc()
193189

194190
var res tagquery.Tags
195-
var matches []int
196191
for i := range e.filters {
197192
if e.filters[i](id, name, tags) == tagquery.Pass {
198193
res = append(res, e.tags[i]...)
199-
matches = append(matches, i)
200194
}
201195
}
202196

203-
e.cache.Add(sum, res)
197+
e.cache.Add(id.Key, res)
204198

205199
return res
206200
}

0 commit comments

Comments
 (0)