Merge pull request #118960 from MikeSpreitzer/add-seat-occupancy-metric
Introduce apiserver_flowcontrol_current_executing_seats metric
This commit is contained in:
		| @@ -726,7 +726,7 @@ func (qs *queueSet) dispatchSansQueueLocked(ctx context.Context, workEstimate *f | |||||||
| 	qs.totRequestsExecuting++ | 	qs.totRequestsExecuting++ | ||||||
| 	qs.totSeatsInUse += req.MaxSeats() | 	qs.totSeatsInUse += req.MaxSeats() | ||||||
| 	metrics.AddRequestsExecuting(ctx, qs.qCfg.Name, fsName, 1) | 	metrics.AddRequestsExecuting(ctx, qs.qCfg.Name, fsName, 1) | ||||||
| 	metrics.AddRequestConcurrencyInUse(qs.qCfg.Name, fsName, req.MaxSeats()) | 	metrics.AddSeatConcurrencyInUse(qs.qCfg.Name, fsName, req.MaxSeats()) | ||||||
| 	qs.reqsGaugePair.RequestsExecuting.Add(1) | 	qs.reqsGaugePair.RequestsExecuting.Add(1) | ||||||
| 	qs.execSeatsGauge.Add(float64(req.MaxSeats())) | 	qs.execSeatsGauge.Add(float64(req.MaxSeats())) | ||||||
| 	qs.seatDemandIntegrator.Set(float64(qs.totSeatsInUse + qs.totSeatsWaiting)) | 	qs.seatDemandIntegrator.Set(float64(qs.totSeatsInUse + qs.totSeatsWaiting)) | ||||||
| @@ -771,7 +771,7 @@ func (qs *queueSet) dispatchLocked() bool { | |||||||
| 	queue.requestsExecuting++ | 	queue.requestsExecuting++ | ||||||
| 	queue.seatsInUse += request.MaxSeats() | 	queue.seatsInUse += request.MaxSeats() | ||||||
| 	metrics.AddRequestsExecuting(request.ctx, qs.qCfg.Name, request.fsName, 1) | 	metrics.AddRequestsExecuting(request.ctx, qs.qCfg.Name, request.fsName, 1) | ||||||
| 	metrics.AddRequestConcurrencyInUse(qs.qCfg.Name, request.fsName, request.MaxSeats()) | 	metrics.AddSeatConcurrencyInUse(qs.qCfg.Name, request.fsName, request.MaxSeats()) | ||||||
| 	qs.reqsGaugePair.RequestsExecuting.Add(1) | 	qs.reqsGaugePair.RequestsExecuting.Add(1) | ||||||
| 	qs.execSeatsGauge.Add(float64(request.MaxSeats())) | 	qs.execSeatsGauge.Add(float64(request.MaxSeats())) | ||||||
| 	qs.seatDemandIntegrator.Set(float64(qs.totSeatsInUse + qs.totSeatsWaiting)) | 	qs.seatDemandIntegrator.Set(float64(qs.totSeatsInUse + qs.totSeatsWaiting)) | ||||||
| @@ -938,7 +938,7 @@ func (qs *queueSet) finishRequestLocked(r *request) { | |||||||
| 		defer qs.removeQueueIfEmptyLocked(r) | 		defer qs.removeQueueIfEmptyLocked(r) | ||||||
|  |  | ||||||
| 		qs.totSeatsInUse -= r.MaxSeats() | 		qs.totSeatsInUse -= r.MaxSeats() | ||||||
| 		metrics.AddRequestConcurrencyInUse(qs.qCfg.Name, r.fsName, -r.MaxSeats()) | 		metrics.AddSeatConcurrencyInUse(qs.qCfg.Name, r.fsName, -r.MaxSeats()) | ||||||
| 		qs.execSeatsGauge.Add(-float64(r.MaxSeats())) | 		qs.execSeatsGauge.Add(-float64(r.MaxSeats())) | ||||||
| 		qs.seatDemandIntegrator.Set(float64(qs.totSeatsInUse + qs.totSeatsWaiting)) | 		qs.seatDemandIntegrator.Set(float64(qs.totSeatsInUse + qs.totSeatsWaiting)) | ||||||
| 		if r.queue != nil { | 		if r.queue != nil { | ||||||
|   | |||||||
| @@ -241,16 +241,27 @@ var ( | |||||||
| 		}, | 		}, | ||||||
| 		[]string{priorityLevel, flowSchema}, | 		[]string{priorityLevel, flowSchema}, | ||||||
| 	) | 	) | ||||||
| 	apiserverRequestConcurrencyInUse = compbasemetrics.NewGaugeVec( | 	apiserverCurrentExecutingSeats = compbasemetrics.NewGaugeVec( | ||||||
| 		&compbasemetrics.GaugeOpts{ | 		&compbasemetrics.GaugeOpts{ | ||||||
| 			Namespace:      namespace, | 			Namespace:      namespace, | ||||||
| 			Subsystem:      subsystem, | 			Subsystem:      subsystem, | ||||||
| 			Name:           "request_concurrency_in_use", | 			Name:           "current_executing_seats", | ||||||
| 			Help:           "Concurrency (number of seats) occupied by the currently executing (initial stage for a WATCH, any stage otherwise) requests in the API Priority and Fairness subsystem", | 			Help:           "Concurrency (number of seats) occupied by the currently executing (initial stage for a WATCH, any stage otherwise) requests in the API Priority and Fairness subsystem", | ||||||
| 			StabilityLevel: compbasemetrics.ALPHA, | 			StabilityLevel: compbasemetrics.ALPHA, | ||||||
| 		}, | 		}, | ||||||
| 		[]string{priorityLevel, flowSchema}, | 		[]string{priorityLevel, flowSchema}, | ||||||
| 	) | 	) | ||||||
|  | 	apiserverRequestConcurrencyInUse = compbasemetrics.NewGaugeVec( | ||||||
|  | 		&compbasemetrics.GaugeOpts{ | ||||||
|  | 			Namespace:         namespace, | ||||||
|  | 			Subsystem:         subsystem, | ||||||
|  | 			Name:              "request_concurrency_in_use", | ||||||
|  | 			Help:              "Concurrency (number of seats) occupied by the currently executing (initial stage for a WATCH, any stage otherwise) requests in the API Priority and Fairness subsystem", | ||||||
|  | 			DeprecatedVersion: "1.28.0", | ||||||
|  | 			StabilityLevel:    compbasemetrics.ALPHA, | ||||||
|  | 		}, | ||||||
|  | 		[]string{priorityLevel, flowSchema}, | ||||||
|  | 	) | ||||||
| 	apiserverRequestWaitingSeconds = compbasemetrics.NewHistogramVec( | 	apiserverRequestWaitingSeconds = compbasemetrics.NewHistogramVec( | ||||||
| 		&compbasemetrics.HistogramOpts{ | 		&compbasemetrics.HistogramOpts{ | ||||||
| 			Namespace:      namespace, | 			Namespace:      namespace, | ||||||
| @@ -444,6 +455,7 @@ var ( | |||||||
| 		apiserverRequestQueueLength, | 		apiserverRequestQueueLength, | ||||||
| 		apiserverRequestConcurrencyLimit, | 		apiserverRequestConcurrencyLimit, | ||||||
| 		apiserverRequestConcurrencyInUse, | 		apiserverRequestConcurrencyInUse, | ||||||
|  | 		apiserverCurrentExecutingSeats, | ||||||
| 		apiserverCurrentExecutingRequests, | 		apiserverCurrentExecutingRequests, | ||||||
| 		apiserverRequestWaitingSeconds, | 		apiserverRequestWaitingSeconds, | ||||||
| 		apiserverRequestExecutionSeconds, | 		apiserverRequestExecutionSeconds, | ||||||
| @@ -523,9 +535,10 @@ func SetDispatchMetrics(priorityLevel string, r, s, sMin, sMax, discountedSMin, | |||||||
| 	apiserverNextDiscountedSBounds.WithLabelValues(priorityLevel, "max").Set(discountedSMax) | 	apiserverNextDiscountedSBounds.WithLabelValues(priorityLevel, "max").Set(discountedSMax) | ||||||
| } | } | ||||||
|  |  | ||||||
| // AddRequestConcurrencyInUse adds the given delta to the gauge of concurrency in use by | // AddSeatConcurrencyInUse adds the given delta to the gauge of seats in use by | ||||||
| // the currently executing requests of the given flowSchema and priorityLevel | // the currently executing requests of the given flowSchema and priorityLevel | ||||||
| func AddRequestConcurrencyInUse(priorityLevel, flowSchema string, delta int) { | func AddSeatConcurrencyInUse(priorityLevel, flowSchema string, delta int) { | ||||||
|  | 	apiserverCurrentExecutingSeats.WithLabelValues(priorityLevel, flowSchema).Add(float64(delta)) | ||||||
| 	apiserverRequestConcurrencyInUse.WithLabelValues(priorityLevel, flowSchema).Add(float64(delta)) | 	apiserverRequestConcurrencyInUse.WithLabelValues(priorityLevel, flowSchema).Add(float64(delta)) | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Kubernetes Prow Robot
					Kubernetes Prow Robot