Adds QueueUsage to prometheus metrics (same as /api/stat/app) (#401)
Exposes gorush_queue_usage metric to be used in prometheus so monitor internal queues Useful to make sure we are coping well with traffic
This commit is contained in:
@@ -14,6 +14,7 @@ type Metrics struct {
|
|||||||
IosError *prometheus.Desc
|
IosError *prometheus.Desc
|
||||||
AndroidSuccess *prometheus.Desc
|
AndroidSuccess *prometheus.Desc
|
||||||
AndroidError *prometheus.Desc
|
AndroidError *prometheus.Desc
|
||||||
|
QueueUsage *prometheus.Desc
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewMetrics returns a new Metrics with all prometheus.Desc initialized
|
// NewMetrics returns a new Metrics with all prometheus.Desc initialized
|
||||||
@@ -45,6 +46,11 @@ func NewMetrics() Metrics {
|
|||||||
"Number of android fail count",
|
"Number of android fail count",
|
||||||
nil, nil,
|
nil, nil,
|
||||||
),
|
),
|
||||||
|
QueueUsage: prometheus.NewDesc(
|
||||||
|
namespace+"queue_usage",
|
||||||
|
"Length of internal queue",
|
||||||
|
nil, nil,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,6 +61,7 @@ func (c Metrics) Describe(ch chan<- *prometheus.Desc) {
|
|||||||
ch <- c.IosError
|
ch <- c.IosError
|
||||||
ch <- c.AndroidSuccess
|
ch <- c.AndroidSuccess
|
||||||
ch <- c.AndroidError
|
ch <- c.AndroidError
|
||||||
|
ch <- c.QueueUsage
|
||||||
}
|
}
|
||||||
|
|
||||||
// Collect returns the metrics with values
|
// Collect returns the metrics with values
|
||||||
@@ -84,4 +91,9 @@ func (c Metrics) Collect(ch chan<- prometheus.Metric) {
|
|||||||
prometheus.GaugeValue,
|
prometheus.GaugeValue,
|
||||||
float64(StatStorage.GetAndroidError()),
|
float64(StatStorage.GetAndroidError()),
|
||||||
)
|
)
|
||||||
|
ch <- prometheus.MustNewConstMetric(
|
||||||
|
c.QueueUsage,
|
||||||
|
prometheus.GaugeValue,
|
||||||
|
float64(len(QueueNotification)),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user