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)
| 282 | // Format: {context}.{label_value1}_{label_value2}_... |
| 283 | // Label order is ALWAYS from the context definition, ensuring consistency |
| 284 | func 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 | |
| 304 | func getContextMetadata(ctx any) *ContextMetadata { |
| 305 | // Extract metadata from Context[T] using reflection |
no test coverage detected
searching dependent graphs…