|
7 | 7 |
|
8 | 8 | "github.com/pkg/errors"
|
9 | 9 | "github.com/prometheus/client_golang/prometheus"
|
| 10 | + "github.com/prometheus/client_golang/prometheus/promauto" |
10 | 11 | "go.uber.org/atomic"
|
11 | 12 |
|
12 | 13 | "github.com/cortexproject/cortex/pkg/util/services"
|
@@ -58,15 +59,20 @@ type RequestQueue struct {
|
58 | 59 | stopped bool
|
59 | 60 |
|
60 | 61 | queueLength *prometheus.GaugeVec // Per user and reason.
|
| 62 | + totalRequests *prometheus.CounterVec // Per user. |
61 | 63 | discardedRequests *prometheus.CounterVec // Per user.
|
62 | 64 | }
|
63 | 65 |
|
64 |
| -func NewRequestQueue(maxOutstandingPerTenant int, forgetDelay time.Duration, queueLength *prometheus.GaugeVec, discardedRequests *prometheus.CounterVec, limits Limits) *RequestQueue { |
| 66 | +func NewRequestQueue(maxOutstandingPerTenant int, forgetDelay time.Duration, queueLength *prometheus.GaugeVec, discardedRequests *prometheus.CounterVec, limits Limits, registerer prometheus.Registerer) *RequestQueue { |
65 | 67 | q := &RequestQueue{
|
66 | 68 | queues: newUserQueues(maxOutstandingPerTenant, forgetDelay, limits),
|
67 | 69 | connectedQuerierWorkers: atomic.NewInt32(0),
|
68 | 70 | queueLength: queueLength,
|
69 |
| - discardedRequests: discardedRequests, |
| 71 | + totalRequests: promauto.With(registerer).NewCounterVec(prometheus.CounterOpts{ |
| 72 | + Name: "cortex_request_queue_requests_total", |
| 73 | + Help: "Total number of query requests going to the request queue.", |
| 74 | + }, []string{"user"}), |
| 75 | + discardedRequests: discardedRequests, |
70 | 76 | }
|
71 | 77 |
|
72 | 78 | q.cond = sync.NewCond(&q.mtx)
|
@@ -94,6 +100,7 @@ func (q *RequestQueue) EnqueueRequest(userID string, req Request, maxQueriers in
|
94 | 100 | return errors.New("no queue found")
|
95 | 101 | }
|
96 | 102 |
|
| 103 | + q.totalRequests.WithLabelValues(userID).Inc() |
97 | 104 | select {
|
98 | 105 | case queue <- req:
|
99 | 106 | q.queueLength.WithLabelValues(userID).Inc()
|
|
0 commit comments