mv metrics to github.com/go-gost/x

This commit is contained in:
ginuerzh
2022-04-05 17:55:20 +08:00
parent d6e6efb093
commit c2f49e9444
9 changed files with 190 additions and 479 deletions

43
metrics/noop.go Normal file
View File

@ -0,0 +1,43 @@
package metrics
var (
nopGauge = &noopGauge{}
nopCounter = &noopCounter{}
nopObserver = &noopObserver{}
noop Metrics = &noopMetrics{}
)
type noopMetrics struct{}
func Noop() Metrics {
return noop
}
func (m *noopMetrics) Counter(name MetricName, labels Labels) Counter {
return nopCounter
}
func (m *noopMetrics) Gauge(name MetricName, labels Labels) Gauge {
return nopGauge
}
func (m *noopMetrics) Observer(name MetricName, labels Labels) Observer {
return nopObserver
}
type noopGauge struct{}
func (*noopGauge) Inc() {}
func (*noopGauge) Dec() {}
func (*noopGauge) Add(v float64) {}
func (*noopGauge) Set(v float64) {}
type noopCounter struct{}
func (*noopCounter) Inc() {}
func (*noopCounter) Add(v float64) {}
type noopObserver struct{}
func (*noopObserver) Observe(v float64) {}