mirror of
https://github.com/prometheus/statsd_exporter.git
synced 2024-12-24 14:30:29 +00:00
use label for metric type and decrement
Signed-off-by: Brian Akins <brian@akins.org>
This commit is contained in:
parent
92957ce080
commit
45402964a4
2 changed files with 11 additions and 6 deletions
12
exporter.go
12
exporter.go
|
@ -102,7 +102,7 @@ func (c *CounterContainer) Get(metricName string, labels prometheus.Labels, help
|
|||
|
||||
counterVec, ok := c.Elements[mapKey]
|
||||
if !ok {
|
||||
metricsCount.Inc()
|
||||
metricsCount.WithLabelValues("counter").Inc()
|
||||
counterVec = prometheus.NewCounterVec(prometheus.CounterOpts{
|
||||
Name: metricName,
|
||||
Help: help,
|
||||
|
@ -120,6 +120,7 @@ func (c *CounterContainer) Delete(metricName string, labels prometheus.Labels) {
|
|||
mapKey := getContainerMapKey(metricName, labelNames)
|
||||
if _, ok := c.Elements[mapKey]; ok {
|
||||
c.Elements[mapKey].Delete(labels)
|
||||
metricsCount.WithLabelValues("counter").Dec()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -139,7 +140,7 @@ func (c *GaugeContainer) Get(metricName string, labels prometheus.Labels, help s
|
|||
|
||||
gaugeVec, ok := c.Elements[mapKey]
|
||||
if !ok {
|
||||
metricsCount.Inc()
|
||||
metricsCount.WithLabelValues("gauge").Inc()
|
||||
gaugeVec = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||
Name: metricName,
|
||||
Help: help,
|
||||
|
@ -157,6 +158,7 @@ func (c *GaugeContainer) Delete(metricName string, labels prometheus.Labels) {
|
|||
mapKey := getContainerMapKey(metricName, labelNames)
|
||||
if _, ok := c.Elements[mapKey]; ok {
|
||||
c.Elements[mapKey].Delete(labels)
|
||||
metricsCount.WithLabelValues("gauge").Dec()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -178,7 +180,7 @@ func (c *SummaryContainer) Get(metricName string, labels prometheus.Labels, help
|
|||
|
||||
summaryVec, ok := c.Elements[mapKey]
|
||||
if !ok {
|
||||
metricsCount.Inc()
|
||||
metricsCount.WithLabelValues("summary").Inc()
|
||||
quantiles := c.mapper.Defaults.Quantiles
|
||||
if mapping != nil && mapping.Quantiles != nil && len(mapping.Quantiles) > 0 {
|
||||
quantiles = mapping.Quantiles
|
||||
|
@ -206,6 +208,7 @@ func (c *SummaryContainer) Delete(metricName string, labels prometheus.Labels) {
|
|||
mapKey := getContainerMapKey(metricName, labelNames)
|
||||
if _, ok := c.Elements[mapKey]; ok {
|
||||
c.Elements[mapKey].Delete(labels)
|
||||
metricsCount.WithLabelValues("summary").Dec()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -227,7 +230,7 @@ func (c *HistogramContainer) Get(metricName string, labels prometheus.Labels, he
|
|||
|
||||
histogramVec, ok := c.Elements[mapKey]
|
||||
if !ok {
|
||||
metricsCount.Inc()
|
||||
metricsCount.WithLabelValues("histogram").Inc()
|
||||
buckets := c.mapper.Defaults.Buckets
|
||||
if mapping != nil && mapping.Buckets != nil && len(mapping.Buckets) > 0 {
|
||||
buckets = mapping.Buckets
|
||||
|
@ -251,6 +254,7 @@ func (c *HistogramContainer) Delete(metricName string, labels prometheus.Labels)
|
|||
mapKey := getContainerMapKey(metricName, labelNames)
|
||||
if _, ok := c.Elements[mapKey]; ok {
|
||||
c.Elements[mapKey].Delete(labels)
|
||||
metricsCount.WithLabelValues("histogram").Dec()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -116,11 +116,12 @@ var (
|
|||
},
|
||||
[]string{"action"},
|
||||
)
|
||||
metricsCount = prometheus.NewCounter(
|
||||
prometheus.CounterOpts{
|
||||
metricsCount = prometheus.NewGaugeVec(
|
||||
prometheus.GaugeOpts{
|
||||
Name: "statsd_exporter_metrics_total",
|
||||
Help: "The total number of metrics.",
|
||||
},
|
||||
[]string{"type"},
|
||||
)
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue