MCPcopy Index your code
hub / github.com/coder/coder / LabelsEqual

Function LabelsEqual

agent/proto/compare.go:3–26  ·  view source on GitHub ↗
(a, b []*Stats_Metric_Label)

Source from the content-addressed store, hash-verified

1package proto
2
3func LabelsEqual(a, b []*Stats_Metric_Label) bool {
4 am := make(map[string]string, len(a))
5 for _, lbl := range a {
6 v := lbl.GetValue()
7 if v == "" {
8 // Prometheus considers empty labels as equivalent to being absent
9 continue
10 }
11 am[lbl.GetName()] = lbl.GetValue()
12 }
13 lenB := 0
14 for _, lbl := range b {
15 v := lbl.GetValue()
16 if v == "" {
17 // Prometheus considers empty labels as equivalent to being absent
18 continue
19 }
20 lenB++
21 if am[lbl.GetName()] != v {
22 return false
23 }
24 }
25 return len(am) == lenB
26}

Callers 1

TestLabelsEqualFunction · 0.92

Calls 2

GetValueMethod · 0.45
GetNameMethod · 0.45

Tested by 1

TestLabelsEqualFunction · 0.74