@@ -420,7 +420,7 @@ func (s *VllmSimulator) processing(ctx context.Context) {
420420
421421			s .logger .V (4 ).Info ("Sending the request to the processing channel" , "model" , model ,
422422				"req id" , reqCtx .CompletionReq .GetRequestID (), "worker" , worker .id )
423- 			worker .reqChan   <-   reqCtx 
423+ 			common . WriteToChannel ( worker .reqChan ,  reqCtx ,  s . logger ,  "worker's reqChan" ) 
424424		}
425425	}
426426}
@@ -431,9 +431,9 @@ func (s *VllmSimulator) findRequestAndSendToProcess(worker *worker) bool {
431431		// send this request for processing in this worker 
432432		s .logger .V (4 ).Info ("Sending request to processing" , "model" , nextReq .CompletionReq .GetModel (),
433433			"req" , nextReq .CompletionReq .GetRequestID (), "worker" , worker .id )
434- 		worker .reqChan   <-   nextReq 
434+ 		common . WriteToChannel ( worker .reqChan ,  nextReq ,  s . logger ,  "worker's reqChan" ) 
435435		// decrement waiting requests metric 
436- 		s .metrics .waitingReqChan   <-   - 1 
436+ 		common . WriteToChannel ( s .metrics .waitingReqChan ,  - 1 ,  s . logger ,  "metrics.waitingReqChan" ) 
437437		return  true 
438438	}
439439
@@ -450,9 +450,11 @@ func (s *VllmSimulator) addRequestToQueue(reqCtx *openaiserverapi.CompletionReqC
450450		return 
451451	}
452452	// increment the waiting requests metric 
453- 	s .metrics .waitingReqChan   <-   1 
453+ 	common . WriteToChannel ( s .metrics .waitingReqChan ,  1 ,  s . logger ,  "metrics.waitingReqChan" ) 
454454	// update loraInfo metrics with the new waiting request 
455- 	s .metrics .lorasChan  <-  loraUsage {reqCtx .CompletionReq .GetModel (), waitingUsageState }
455+ 	common .WriteToChannel (s .metrics .lorasChan , loraUsage {reqCtx .CompletionReq .GetModel (), waitingUsageState },
456+ 		s .logger , "metrics.lorasChan" )
457+ 
456458}
457459
458460// handleCompletions general completion requests handler, support both text and chat completion APIs 
@@ -487,18 +489,19 @@ func (s *VllmSimulator) handleCompletions(ctx *fasthttp.RequestCtx, isChatComple
487489		IsChatCompletion : isChatCompletion ,
488490		Wg :               & wg ,
489491	}
490- 	s .newRequests   <-   reqCtx 
492+ 	common . WriteToChannel ( s .newRequests ,  reqCtx ,  s . logger ,  "newRequests" ) 
491493	wg .Wait ()
492494}
493495
494496// request processing finished 
495497func  (s  * VllmSimulator ) responseSentCallback (model  string , isChatCompletion  bool , requestID  string ) {
496498	// decrement running requests count 
497- 	s .metrics .runReqChan   <-   - 1 
499+ 	common . WriteToChannel ( s .metrics .runReqChan ,  - 1 ,  s . logger ,  "metrics.runReqChan" ) 
498500
499501	if  s .isLora (model ) {
500502		// update loraInfo metrics to reflect that the request processing has been finished 
501- 		s .metrics .lorasChan  <-  loraUsage {model , doneUsageState }
503+ 		common .WriteToChannel (s .metrics .lorasChan , loraUsage {model , doneUsageState },
504+ 			s .logger , "metrics.lorasChan" )
502505	}
503506
504507	if  s .config .EnableKVCache  &&  ! isChatCompletion  {
@@ -580,14 +583,14 @@ func (s *VllmSimulator) sendResponse(reqCtx *openaiserverapi.CompletionReqCtx, r
580583	time .Sleep (time .Duration (ttft ) *  time .Millisecond )
581584
582585	// report ttft in seconds 
583- 	s .metrics .ttftChan   <-   (float64 (ttft ) /  1000 )
586+ 	common . WriteToChannel ( s .metrics .ttftChan ,  (float64 (ttft ) /  1000 ),  s . logger ,  "metrics.ttftChan" )
584587
585588	for  range  usageData .CompletionTokens  -  1  {
586589		perTokenLatency  :=  s .getInterTokenLatency ()
587590		time .Sleep (time .Duration (perTokenLatency ) *  time .Millisecond )
588591
589592		// report tpot in seconds 
590- 		s .metrics .tpotChan   <-   float64 (perTokenLatency ) /  1000 
593+ 		common . WriteToChannel ( s .metrics .tpotChan , ( float64 (perTokenLatency ) /  1000 ),  s . logger ,  "metrics.tpotChan" ) 
591594	}
592595	s .sendCompletionResponse (reqCtx .HTTPReqCtx , resp )
593596
0 commit comments