change names for stats sub-collectors
This commit is contained in:
@ -6,22 +6,22 @@ import (
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
type clientsCollector []struct {
|
||||
type clientStats []struct {
|
||||
val func(*client) float64
|
||||
vec *prometheus.GaugeVec
|
||||
}
|
||||
|
||||
// ClientsCollector creates a new stats collector which is able to
|
||||
// ClientStats creates a new stats collector which is able to
|
||||
// expose the client metrics of a nsqd node to Prometheus. The
|
||||
// client metrics are reported per topic and per channel.
|
||||
//
|
||||
// If there are too many clients, it could cause a timeout of the
|
||||
// Prometheus collection process. So be sure the number of clients
|
||||
// is small enough when using this collector.
|
||||
func ClientsCollector(namespace string) StatsCollector {
|
||||
func ClientStats(namespace string) StatsCollector {
|
||||
labels := []string{"type", "topic", "channel", "deflate", "snappy", "tls", "client_id", "hostname", "version", "remote_address"}
|
||||
|
||||
return clientsCollector{
|
||||
return clientStats{
|
||||
{
|
||||
// TODO: Give state a descriptive name instead of a number.
|
||||
val: func(c *client) float64 { return float64(c.State) },
|
||||
@ -90,7 +90,7 @@ func ClientsCollector(namespace string) StatsCollector {
|
||||
}
|
||||
}
|
||||
|
||||
func (coll clientsCollector) collect(s *stats, out chan<- prometheus.Metric) {
|
||||
func (cs clientStats) collect(s *stats, out chan<- prometheus.Metric) {
|
||||
for _, topic := range s.Topics {
|
||||
for _, channel := range topic.Channels {
|
||||
for _, client := range channel.Clients {
|
||||
@ -107,7 +107,7 @@ func (coll clientsCollector) collect(s *stats, out chan<- prometheus.Metric) {
|
||||
"remote_address": client.RemoteAddress,
|
||||
}
|
||||
|
||||
for _, c := range coll {
|
||||
for _, c := range cs {
|
||||
c.vec.With(labels).Set(c.val(client))
|
||||
c.vec.Collect(out)
|
||||
}
|
||||
|
Reference in New Issue
Block a user