MCPcopy
hub / github.com/netdata/netdata / compileInstanceByLabels

Function compileInstanceByLabels

src/go/plugin/framework/chartengine/compiler.go:345–366  ·  view source on GitHub ↗
(instances *charttpl.Instances)

Source from the content-addressed store, hash-verified

343}
344
345func compileInstanceByLabels(instances *charttpl.Instances) ([]program.InstanceLabelSelector, error) {
346 if instances == nil {
347 return nil, nil
348 }
349 out := make([]program.InstanceLabelSelector, 0, len(instances.ByLabels))
350 for _, token := range instances.ByLabels {
351 t := strings.TrimSpace(token)
352 switch {
353 case t == "*":
354 out = append(out, program.InstanceLabelSelector{IncludeAll: true})
355 case strings.HasPrefix(t, "!"):
356 key := strings.TrimSpace(strings.TrimPrefix(t, "!"))
357 if key == "" {
358 return nil, fmt.Errorf("exclude token must include label key")
359 }
360 out = append(out, program.InstanceLabelSelector{Exclude: true, Key: key})
361 default:
362 out = append(out, program.InstanceLabelSelector{Key: t})
363 }
364 }
365 return out, nil
366}
367
368func metricKindsFromNames(names []string) []string {
369 seen := make(map[string]struct{})

Callers 1

compileChartMethod · 0.85

Calls 1

ErrorfMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…