package util12import (3"sync"45"github.com/prometheus/client_golang/prometheus"6)78// UncheckedCollector is a prometheus.Collector which stores a set of unchecked9// metrics.10type UncheckedCollector struct {11mut sync.RWMutex12inner prometheus.Collector13}1415var _ prometheus.Collector = (*UncheckedCollector)(nil)1617// NewUncheckedCollector creates a new UncheckedCollector. If inner is nil,18// UncheckedCollector returns no metrics.19func NewUncheckedCollector(inner prometheus.Collector) *UncheckedCollector {20return &UncheckedCollector{inner: inner}21}2223// SetCollector replaces the inner collector.24func (uc *UncheckedCollector) SetCollector(inner prometheus.Collector) {25uc.mut.Lock()26defer uc.mut.Unlock()2728uc.inner = inner29}3031// Describe implements [prometheus.Collector], but is a no-op to be considered32// an "unchecked" collector by Prometheus. See [prometheus.Collector] for more33// information.34func (uc *UncheckedCollector) Describe(_ chan<- *prometheus.Desc) {35// No-op: do not send any descriptions of metrics to avoid having them be36// checked.37}3839// Collector implements [prometheus.Collector]. If the UncheckedCollector has a40// non-nil inner collector, metrics will be collected from it.41func (uc *UncheckedCollector) Collect(ch chan<- prometheus.Metric) {42uc.mut.RLock()43defer uc.mut.RUnlock()4445if uc.inner != nil {46uc.inner.Collect(ch)47}48}495051