|
6 | 6 | "unsafe"
|
7 | 7 |
|
8 | 8 | "github.com/grafana/metrictank/stats"
|
9 |
| - "github.com/grafana/metrictank/util" |
10 | 9 |
|
11 | 10 | "github.com/grafana/metrictank/errors"
|
12 | 11 | "github.com/grafana/metrictank/expr/tagquery"
|
@@ -175,32 +174,27 @@ func (e *enricher) reportStats() {
|
175 | 174 | enrichmentCacheEntries.Set(e.cache.Len())
|
176 | 175 | }
|
177 | 176 |
|
| 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. |
178 | 182 | 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) |
188 | 184 | if ok {
|
189 | 185 | enrichmentCacheHits.Inc()
|
190 | 186 | return cachedRes.(tagquery.Tags)
|
191 | 187 | }
|
192 | 188 | enrichmentCacheMisses.Inc()
|
193 | 189 |
|
194 | 190 | var res tagquery.Tags
|
195 |
| - var matches []int |
196 | 191 | for i := range e.filters {
|
197 | 192 | if e.filters[i](id, name, tags) == tagquery.Pass {
|
198 | 193 | res = append(res, e.tags[i]...)
|
199 |
| - matches = append(matches, i) |
200 | 194 | }
|
201 | 195 | }
|
202 | 196 |
|
203 |
| - e.cache.Add(sum, res) |
| 197 | + e.cache.Add(id.Key, res) |
204 | 198 |
|
205 | 199 | return res
|
206 | 200 | }
|
|
0 commit comments