diff --git a/gorush/metrics.go b/gorush/metrics.go index 0137890..74e0922 100644 --- a/gorush/metrics.go +++ b/gorush/metrics.go @@ -14,6 +14,7 @@ type Metrics struct { IosError *prometheus.Desc AndroidSuccess *prometheus.Desc AndroidError *prometheus.Desc + QueueUsage *prometheus.Desc } // NewMetrics returns a new Metrics with all prometheus.Desc initialized @@ -45,6 +46,11 @@ func NewMetrics() Metrics { "Number of android fail count", 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.AndroidSuccess ch <- c.AndroidError + ch <- c.QueueUsage } // Collect returns the metrics with values @@ -84,4 +91,9 @@ func (c Metrics) Collect(ch chan<- prometheus.Metric) { prometheus.GaugeValue, float64(StatStorage.GetAndroidError()), ) + ch <- prometheus.MustNewConstMetric( + c.QueueUsage, + prometheus.GaugeValue, + float64(len(QueueNotification)), + ) }