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)
| 618 | // If hard is true, registry is removed completely. |
| 619 | // If hard is false, latest registry values are preserved for future aggregations. |
| 620 | func (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. |