@@ -19,23 +19,24 @@ import (
1919// parameter.
2020// Envoy sends the request body to ext proc before sending the request to the backend server.
2121func (s * Server ) HandleRequestBody (reqCtx * RequestContext , req * extProcPb.ProcessingRequest ) (* extProcPb.ProcessingResponse , error ) {
22- klog .V (logutil .VERBOSE ).Infof ("Handling request body" )
22+ klogV := klog .V (logutil .VERBOSE )
23+ klogV .InfoS ("Handling request body" )
2324
2425 // Unmarshal request body (must be JSON).
2526 v := req .Request .(* extProcPb.ProcessingRequest_RequestBody )
2627 var rb map [string ]interface {}
2728 if err := json .Unmarshal (v .RequestBody .Body , & rb ); err != nil {
28- klog .Errorf ( "Error unmarshaling request body: %v" , err )
29+ klog .V ( logutil . DEFAULT ). ErrorS ( err , "Error unmarshaling request body" )
2930 return nil , fmt .Errorf ("error unmarshaling request body: %v" , err )
3031 }
31- klog . V ( logutil . VERBOSE ). Infof ( "Request body: %v " , rb )
32+ klogV . InfoS ( "Request body unmarshalled" , "body " , rb )
3233
3334 // Resolve target models.
3435 model , ok := rb ["model" ].(string )
3536 if ! ok {
3637 return nil , errors .New ("model not found in request" )
3738 }
38- klog . V ( logutil . VERBOSE ). Infof ( "Model requested: %v " , model )
39+ klogV . InfoS ( "Model requested" , "model " , model )
3940 modelName := model
4041
4142 // NOTE: The nil checking for the modelObject means that we DO allow passthrough currently.
@@ -56,7 +57,7 @@ func (s *Server) HandleRequestBody(reqCtx *RequestContext, req *extProcPb.Proces
5657 ResolvedTargetModel : modelName ,
5758 Critical : backend .IsCritical (modelObj ),
5859 }
59- klog . V ( logutil . VERBOSE ). Infof ( "LLM Request: %+v " , llmReq )
60+ klogV . InfoS ( "LLM request assembled" , "request " , llmReq )
6061
6162 requestBody := v .RequestBody .Body
6263 var err error
@@ -65,17 +66,17 @@ func (s *Server) HandleRequestBody(reqCtx *RequestContext, req *extProcPb.Proces
6566 rb ["model" ] = llmReq .ResolvedTargetModel
6667 requestBody , err = json .Marshal (rb )
6768 if err != nil {
68- klog .Errorf ( "Error marshaling request body: %v" , err )
69+ klog .V ( logutil . DEFAULT ). ErrorS ( err , "Error marshaling request body" )
6970 return nil , fmt .Errorf ("error marshaling request body: %v" , err )
7071 }
71- klog . V ( logutil . VERBOSE ). Infof ( "Updated body: %v " , string (requestBody ))
72+ klogV . InfoS ( "Updated request body marshalled" , "body " , string (requestBody ))
7273 }
7374
7475 targetPod , err := s .scheduler .Schedule (llmReq )
7576 if err != nil {
7677 return nil , fmt .Errorf ("failed to find target pod: %w" , err )
7778 }
78- klog . V ( logutil . VERBOSE ). Infof ( "Selected target model %v in target pod: %v \n " , llmReq .ResolvedTargetModel , targetPod )
79+ klogV . InfoS ( "Target model and pod selected " , "model" , llmReq .ResolvedTargetModel , "pod" , targetPod )
7980
8081 reqCtx .Model = llmReq .Model
8182 reqCtx .ResolvedTargetModel = llmReq .ResolvedTargetModel
@@ -101,7 +102,7 @@ func (s *Server) HandleRequestBody(reqCtx *RequestContext, req *extProcPb.Proces
101102 }
102103 // Print headers for debugging
103104 for _ , header := range headers {
104- klog .V (logutil .VERBOSE ). Infof ( "[request_body] Header Key: %s, Header Value: %s \n " , header .Header .Key , header .Header .RawValue )
105+ klog .V (logutil .DEBUG ). InfoS ( "Request body header" , "key" , header .Header .Key , "value" , header .Header .RawValue )
105106 }
106107
107108 resp := & extProcPb.ProcessingResponse {
@@ -136,10 +137,9 @@ func (s *Server) HandleRequestBody(reqCtx *RequestContext, req *extProcPb.Proces
136137}
137138
138139func HandleRequestHeaders (reqCtx * RequestContext , req * extProcPb.ProcessingRequest ) * extProcPb.ProcessingResponse {
139- klog .V (logutil .VERBOSE ).Info ("Handling request headers ..." )
140140 r := req .Request
141141 h := r .(* extProcPb.ProcessingRequest_RequestHeaders )
142- klog .V (logutil .VERBOSE ).Infof ( "Headers: %+v \n " , h )
142+ klog .V (logutil .VERBOSE ).InfoS ( "Handling request headers" , "headers " , h )
143143
144144 resp := & extProcPb.ProcessingResponse {
145145 Response : & extProcPb.ProcessingResponse_RequestHeaders {
0 commit comments