MCPcopy Create free account
hub / github.com/netdata/netdata / generateInstanceKeyWithOrder

Function generateInstanceKeyWithOrder

src/go/plugin/ibm.d/framework/state.go:284–302  ·  view source on GitHub ↗

generateInstanceKeyWithOrder creates instance key using hardcoded label order Format: {context}.{label_value1}_{label_value2}_... Label order is ALWAYS from the context definition, ensuring consistency

(contextName string, labelKeys []string, labels map[string]string)

Source from the content-addressed store, hash-verified

282// Format: {context}.{label_value1}_{label_value2}_...
283// Label order is ALWAYS from the context definition, ensuring consistency
284func generateInstanceKeyWithOrder(contextName string, labelKeys []string, labels map[string]string) string {
285 if len(labelKeys) == 0 || len(labels) == 0 {
286 return contextName
287 }
288
289 // Build label values in the EXACT order specified in context
290 labelValues := make([]string, 0, len(labelKeys))
291 for _, key := range labelKeys {
292 if value, ok := labels[strings.ToLower(key)]; ok {
293 labelValues = append(labelValues, cleanLabelValue(value))
294 }
295 }
296
297 if len(labelValues) > 0 {
298 return contextName + "." + strings.Join(labelValues, "_")
299 }
300
301 return contextName
302}
303
304func getContextMetadata(ctx any) *ContextMetadata {
305 // Extract metadata from Context[T] using reflection

Callers 1

GetInstanceMethod · 0.85

Calls 1

cleanLabelValueFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…