MCPcopy Index your code
hub / github.com/netdata/netdata / emitChartLabels

Function emitChartLabels

src/go/plugin/framework/chartemit/netdata.go:50–88  ·  view source on GitHub ↗
(api *netdataapi.API, env EmitEnv, chartLabels map[string]string)

Source from the content-addressed store, hash-verified

48}
49
50func emitChartLabels(api *netdataapi.API, env EmitEnv, chartLabels map[string]string) {
51 chartKeys := make([]string, 0, len(chartLabels))
52 for key := range chartLabels {
53 if strings.TrimSpace(key) == "" || key == collectJobReservedLabel {
54 continue
55 }
56 chartKeys = append(chartKeys, key)
57 }
58 sort.Strings(chartKeys)
59
60 keys := make([]string, 0, len(env.JobLabels))
61 for key := range env.JobLabels {
62 if _, overridden := chartLabels[key]; overridden {
63 continue
64 }
65 if key == collectJobReservedLabel {
66 continue
67 }
68 keys = append(keys, key)
69 }
70 sort.Strings(keys)
71 for _, key := range keys {
72 sKey := sanitizeWireID(key)
73 if sKey == "" {
74 continue
75 }
76 api.CLABEL(sKey, sanitizeWireValue(env.JobLabels[key]), labelSourceConf)
77 }
78 for _, key := range chartKeys {
79 sKey := sanitizeWireID(key)
80 if sKey == "" {
81 continue
82 }
83 api.CLABEL(sKey, sanitizeWireValue(chartLabels[key]), labelSourceAuto)
84 }
85 if strings.TrimSpace(env.JobName) != "" {
86 api.CLABEL(collectJobReservedLabel, sanitizeWireValue(env.JobName), labelSourceAuto)
87 }
88}

Callers 1

emitCreatePhaseFunction · 0.85

Calls 3

sanitizeWireIDFunction · 0.85
sanitizeWireValueFunction · 0.85
CLABELMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…