SignatureForLabels works like LabelsToSignature but takes a Metric as parameter (rather than a label map) and only includes the labels with the specified LabelNames into the signature calculation. The labels passed in will be sorted by this function.
(m Metric, labels ...LabelName)
| 96 | // specified LabelNames into the signature calculation. The labels passed in |
| 97 | // will be sorted by this function. |
| 98 | func SignatureForLabels(m Metric, labels ...LabelName) uint64 { |
| 99 | if len(labels) == 0 { |
| 100 | return emptyLabelSignature |
| 101 | } |
| 102 | |
| 103 | sort.Sort(LabelNames(labels)) |
| 104 | |
| 105 | sum := hashNew() |
| 106 | for _, label := range labels { |
| 107 | sum = hashAdd(sum, string(label)) |
| 108 | sum = hashAddByte(sum, SeparatorByte) |
| 109 | sum = hashAdd(sum, string(m[label])) |
| 110 | sum = hashAddByte(sum, SeparatorByte) |
| 111 | } |
| 112 | return sum |
| 113 | } |
| 114 | |
| 115 | // SignatureWithoutLabels works like LabelsToSignature but takes a Metric as |
| 116 | // parameter (rather than a label map) and excludes the labels with any of the |