forked from mirrors/statsd_exporter
a455a8ad64
Signed-off-by: Frank Davidson <davidfr@americas.manulife.net> Signed-off-by: Frank Davidson <ffdavidson@gmail.com>
43 lines
794 B
Go
43 lines
794 B
Go
package metrics
|
|
|
|
import (
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
)
|
|
|
|
type metricType int
|
|
|
|
const (
|
|
CounterMetricType metricType = iota
|
|
GaugeMetricType
|
|
SummaryMetricType
|
|
HistogramMetricType
|
|
)
|
|
|
|
type nameHash uint64
|
|
type valueHash uint64
|
|
type labelHash struct {
|
|
// This is a hash over the label names
|
|
names nameHash
|
|
// This is a hash over the label names + label values
|
|
values valueHash
|
|
}
|
|
|
|
type metricHolder interface{}
|
|
|
|
type vectorHolder interface {
|
|
Delete(label prometheus.Labels) bool
|
|
}
|
|
|
|
type vector struct {
|
|
holder vectorHolder
|
|
refCount uint64
|
|
}
|
|
|
|
type metric struct {
|
|
metricType metricType
|
|
// Vectors key is the hash of the label names
|
|
vectors map[nameHash]*vector
|
|
// Metrics key is a hash of the label names + label values
|
|
metrics map[valueHash]*registeredMetric
|
|
}
|