4f77f87065
Previously, we would emit service usage metrics both with and without a namespace label attached. This is problematic in the case when you want to aggregate metrics together, i.e. "sum(consul.state.services)". This would cause services to be counted twice in that aggregate, once via the metric emitted with a namespace label, and once in the metric emited without any namespace label.
23 lines
494 B
Go
23 lines
494 B
Go
// +build !consulent
|
|
|
|
package usagemetrics
|
|
|
|
import (
|
|
"github.com/armon/go-metrics"
|
|
"github.com/hashicorp/consul/agent/consul/state"
|
|
)
|
|
|
|
func (u *UsageMetricsReporter) emitServiceUsage(serviceUsage state.ServiceUsage) {
|
|
metrics.SetGaugeWithLabels(
|
|
[]string{"consul", "state", "services"},
|
|
float32(serviceUsage.Services),
|
|
u.metricLabels,
|
|
)
|
|
|
|
metrics.SetGaugeWithLabels(
|
|
[]string{"consul", "state", "service_instances"},
|
|
float32(serviceUsage.ServiceInstances),
|
|
u.metricLabels,
|
|
)
|
|
}
|