MCPcopy
hub / github.com/grafana/dskit / AddTenantRegistry

Method AddTenantRegistry

metrics/tenant_registries.go:656–677  ·  view source on GitHub ↗

AddTenantRegistry adds a tenant registry. If tenant already has a registry, previous registry is removed, but latest metric values are preserved in order to avoid counter resets.

(tenant string, reg *prometheus.Registry)

Source from the content-addressed store, hash-verified

654// previous registry is removed, but latest metric values are preserved
655// in order to avoid counter resets.
656func (r *TenantRegistries) AddTenantRegistry(tenant string, reg *prometheus.Registry) {
657 r.regsMu.Lock()
658 defer r.regsMu.Unlock()
659
660 // Soft-remove tenant registry, if tenant has one already.
661 for idx := 0; idx < len(r.regs); {
662 if r.regs[idx].tenant != tenant {
663 idx++
664 continue
665 }
666
667 // Archive and remove the registry.
668 r.archiveTenantRegistry(&r.regs[idx])
669 r.regs = append(r.regs[:idx], r.regs[idx+1:]...)
670 }
671
672 // New registries must be added to the end of the list, to guarantee stability.
673 r.regs = append(r.regs, TenantRegistry{
674 tenant: tenant,
675 reg: reg,
676 })
677}
678
679// RemoveTenantRegistry removes all Prometheus registries for a given tenant.
680// If hard is true, registry is removed completely.

Calls 1

archiveTenantRegistryMethod · 0.95