MCPcopy
hub / github.com/prometheus/client_golang / hashLabelValues

Method hashLabelValues

prometheus/vec.go:250–271  ·  view source on GitHub ↗
(vals []string)

Source from the content-addressed store, hash-verified

248}
249
250func (m *MetricVec) hashLabelValues(vals []string) (uint64, error) {
251 if err := validateLabelValues(vals, len(m.desc.variableLabels.names)-len(m.curry)); err != nil {
252 return 0, err
253 }
254
255 var (
256 h = hashNew()
257 curry = m.curry
258 iVals, iCurry int
259 )
260 for i := 0; i < len(m.desc.variableLabels.names); i++ {
261 if iCurry < len(curry) && curry[iCurry].index == i {
262 h = m.hashAdd(h, curry[iCurry].value)
263 iCurry++
264 } else {
265 h = m.hashAdd(h, vals[iVals])
266 iVals++
267 }
268 h = m.hashAddByte(h, model.SeparatorByte)
269 }
270 return h, nil
271}
272
273func (m *MetricVec) hashLabels(labels Labels) (uint64, error) {
274 if err := validateValuesInLabels(labels, len(m.desc.variableLabels.names)-len(m.curry)); err != nil {

Callers 2

DeleteLabelValuesMethod · 0.95

Calls 2

validateLabelValuesFunction · 0.85
hashNewFunction · 0.85

Tested by

no test coverage detected