MCPcopy
hub / github.com/netdata/netdata / compileGroup

Method compileGroup

src/go/plugin/framework/chartengine/compiler.go:61–90  ·  view source on GitHub ↗
(group charttpl.Group, parent compileScope, groupPath []int)

Source from the content-addressed store, hash-verified

59}
60
61func (c *compiler) compileGroup(group charttpl.Group, parent compileScope, groupPath []int) error {
62 scope := compileScope{
63 metrics: cloneStringSet(parent.metrics),
64 familyParts: append(append([]string(nil), parent.familyParts...), strings.TrimSpace(group.Family)),
65 contextParts: append(append([]string(nil), parent.contextParts...), normalizeOptional(group.ContextNamespace)...),
66 }
67
68 for _, metric := range group.Metrics {
69 name := strings.TrimSpace(metric)
70 scope.metrics[name] = struct{}{}
71 c.metricsSet[name] = struct{}{}
72 }
73
74 for i := range group.Charts {
75 templateID := buildTemplateID(groupPath, i)
76 compiled, err := c.compileChart(group.Charts[i], scope, templateID)
77 if err != nil {
78 return fmt.Errorf("chartengine: compile group[%s] chart[%d]: %w", pathIndexes(groupPath), i, err)
79 }
80 c.charts = append(c.charts, compiled)
81 }
82
83 for i := range group.Groups {
84 nextPath := append(append([]int(nil), groupPath...), i)
85 if err := c.compileGroup(group.Groups[i], scope, nextPath); err != nil {
86 return err
87 }
88 }
89 return nil
90}
91
92func (c *compiler) compileChart(chart charttpl.Chart, scope compileScope, templateID string) (program.Chart, error) {
93 dimensions := make([]program.Dimension, 0, len(chart.Dimensions))

Callers 1

CompileFunction · 0.95

Calls 6

compileChartMethod · 0.95
cloneStringSetFunction · 0.85
normalizeOptionalFunction · 0.85
buildTemplateIDFunction · 0.85
pathIndexesFunction · 0.85
ErrorfMethod · 0.65

Tested by

no test coverage detected