MCPcopy
hub / github.com/netdata/netdata / buildMatchIndex

Function buildMatchIndex

src/go/plugin/framework/chartengine/matcher.go:45–71  ·  view source on GitHub ↗
(charts []program.Chart)

Source from the content-addressed store, hash-verified

43}
44
45func 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
73type routeCache = routecache.RouteCache[routeBinding]
74

Callers 2

LoadMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…