MCPcopy Create free account
hub / github.com/cortexproject/cortex / compareLabels

Method compareLabels

pkg/util/metrics_helper.go:979–1001  ·  view source on GitHub ↗
(labels1, labels2 []*dto.LabelPair)

Source from the content-addressed store, hash-verified

977}
978
979func (m *MetricMap) compareLabels(labels1, labels2 []*dto.LabelPair) bool {
980 if len(labels1) != len(labels2) {
981 return false
982 }
983
984 // create a map of labels for lookup
985 labelMap := make(map[string]string)
986 for _, labelPair := range labels1 {
987 labelMap[labelPair.GetName()] = labelPair.GetValue()
988 }
989
990 for _, labelPair := range labels2 {
991 if value, found := labelMap[labelPair.GetName()]; found {
992 if value != labelPair.GetValue() {
993 return false
994 }
995 } else {
996 return false
997 }
998 }
999
1000 return true
1001}

Callers 1

AddOrSetMetricMethod · 0.95

Calls 2

GetNameMethod · 0.45
GetValueMethod · 0.45

Tested by

no test coverage detected