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

Method Track

pkg/util/labelset/tracker.go:38–50  ·  view source on GitHub ↗

Track accepts userID, label set and hash of the label set limit.

(userId string, hash uint64, labelSet labels.Labels)

Source from the content-addressed store, hash-verified

36
37// Track accepts userID, label set and hash of the label set limit.
38func (m *LabelSetTracker) Track(userId string, hash uint64, labelSet labels.Labels) {
39 s := m.shards[util.HashFP(model.Fingerprint(hash))%numMetricShards]
40 s.Lock()
41 if userEntry, ok := s.userLabelSets[userId]; ok {
42 if _, ok2 := userEntry[hash]; !ok2 {
43 userEntry[hash] = labelSet
44 }
45 } else {
46 s.userLabelSets[userId] = map[uint64]labels.Labels{hash: labelSet}
47 }
48 // Unlock before we update metrics.
49 s.Unlock()
50}
51
52// UpdateMetrics cleans up dangling user and label set from the tracker as well as metrics.
53// It takes a function for user to customize the metrics cleanup logic when either a user or

Callers 2

TestLabelSetTrackerFunction · 0.95

Calls 1

HashFPFunction · 0.92

Tested by 2

TestLabelSetTrackerFunction · 0.76