(charts []program.Chart)
| 43 | } |
| 44 | |
| 45 | func buildMatchIndex(charts []program.Chart) matchIndex { |
| 46 | index := matchIndex{ |
| 47 | chartsByID: make(map[string]program.Chart, len(charts)), |
| 48 | byMetricName: make(map[string][]routeCandidate), |
| 49 | wildcardMatchers: make([]routeCandidate, 0), |
| 50 | } |
| 51 | |
| 52 | for _, chart := range charts { |
| 53 | index.chartsByID[chart.TemplateID] = chart |
| 54 | for i, dim := range chart.Dimensions { |
| 55 | candidate := routeCandidate{ |
| 56 | chartTemplateID: chart.TemplateID, |
| 57 | dimensionIndex: i, |
| 58 | dimension: dim, |
| 59 | } |
| 60 | if len(dim.Selector.MetricNames) == 0 { |
| 61 | index.wildcardMatchers = append(index.wildcardMatchers, candidate) |
| 62 | continue |
| 63 | } |
| 64 | for _, metricName := range dim.Selector.MetricNames { |
| 65 | index.byMetricName[metricName] = append(index.byMetricName[metricName], candidate) |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | return index |
| 71 | } |
| 72 | |
| 73 | type routeCache = routecache.RouteCache[routeBinding] |
| 74 |
no outgoing calls
no test coverage detected
searching dependent graphs…