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

Method RemoveUserRegistry

pkg/util/metrics_helper.go:620–636  ·  view source on GitHub ↗

RemoveUserRegistry removes all Prometheus registries for a given user. If hard is true, registry is removed completely. If hard is false, latest registry values are preserved for future aggregations.

(user string, hard bool)

Source from the content-addressed store, hash-verified

618// If hard is true, registry is removed completely.
619// If hard is false, latest registry values are preserved for future aggregations.
620func (r *UserRegistries) RemoveUserRegistry(user string, hard bool) {
621 r.regsMu.Lock()
622 defer r.regsMu.Unlock()
623
624 for idx := 0; idx < len(r.regs); {
625 if user != r.regs[idx].user {
626 idx++
627 continue
628 }
629
630 if !hard && r.softRemoveUserRegistry(&r.regs[idx]) {
631 idx++ // keep it
632 } else {
633 r.regs = append(r.regs[:idx], r.regs[idx+1:]...) // remove it.
634 }
635 }
636}
637
638// Returns true, if we should keep latest metrics. Returns false if we failed to gather latest metrics,
639// and this can be removed completely.

Calls 1