MCPcopy
hub / github.com/netdata/netdata / Compile

Function Compile

src/go/plugin/framework/chartengine/compiler.go:23–48  ·  view source on GitHub ↗

Compile converts a decoded/default-applied chart template spec into immutable chartengine IR. Callers should prefer charttpl.DecodeYAML, which applies chart_defaults inheritance before validation. Compile validates the provided spec but does not apply charttpl defaults or mutate the input.

(spec *charttpl.Spec, revision uint64)

Source from the content-addressed store, hash-verified

21// inheritance before validation. Compile validates the provided spec but does
22// not apply charttpl defaults or mutate the input.
23func Compile(spec *charttpl.Spec, revision uint64) (*program.Program, error) {
24 if spec == nil {
25 return nil, fmt.Errorf("chartengine: nil template spec")
26 }
27 if err := spec.Validate(); err != nil {
28 return nil, fmt.Errorf("chartengine: invalid template spec: %w", err)
29 }
30
31 c := compiler{
32 metricsSet: make(map[string]struct{}),
33 }
34
35 rootCtx := normalizeOptional(spec.ContextNamespace)
36 for i := range spec.Groups {
37 groupPath := []int{i}
38 if err := c.compileGroup(spec.Groups[i], compileScope{
39 metrics: make(map[string]struct{}),
40 familyParts: nil,
41 contextParts: rootCtx,
42 }, groupPath); err != nil {
43 return nil, err
44 }
45 }
46
47 return program.New(spec.Version, revision, c.metricNames(), c.charts)
48}
49
50type compiler struct {
51 charts []program.Chart

Callers 2

LoadMethod · 0.70
TestCompileScenariosFunction · 0.70

Calls 6

compileGroupMethod · 0.95
metricNamesMethod · 0.95
normalizeOptionalFunction · 0.85
ErrorfMethod · 0.65
ValidateMethod · 0.65
NewMethod · 0.65

Tested by 1

TestCompileScenariosFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…