@@ -19,23 +19,24 @@ import (
19
19
// parameter.
20
20
// Envoy sends the request body to ext proc before sending the request to the backend server.
21
21
func (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" )
23
24
24
25
// Unmarshal request body (must be JSON).
25
26
v := req .Request .(* extProcPb.ProcessingRequest_RequestBody )
26
27
var rb map [string ]interface {}
27
28
if err := json .Unmarshal (v .RequestBody .Body , & rb ); err != nil {
28
- klog .Errorf ( "Error unmarshaling request body: %v" , err )
29
+ klog .ErrorS ( err , "Error unmarshaling request body" )
29
30
return nil , fmt .Errorf ("error unmarshaling request body: %v" , err )
30
31
}
31
- klog . V ( logutil . VERBOSE ). Infof ( "Request body: %v " , rb )
32
+ klogV . InfoS ( "Request body unmarshalled" , "body " , rb )
32
33
33
34
// Resolve target models.
34
35
model , ok := rb ["model" ].(string )
35
36
if ! ok {
36
37
return nil , errors .New ("model not found in request" )
37
38
}
38
- klog . V ( logutil . VERBOSE ). Infof ( "Model requested: %v " , model )
39
+ klogV . InfoS ( "Model requested" , "model " , model )
39
40
modelName := model
40
41
41
42
// 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
56
57
ResolvedTargetModel : modelName ,
57
58
Critical : backend .IsCritical (modelObj ),
58
59
}
59
- klog . V ( logutil . VERBOSE ). Infof ( "LLM Request: %+v " , llmReq )
60
+ klogV . InfoS ( "LLM request assembled" , "request " , llmReq )
60
61
61
62
requestBody := v .RequestBody .Body
62
63
var err error
@@ -65,17 +66,17 @@ func (s *Server) HandleRequestBody(reqCtx *RequestContext, req *extProcPb.Proces
65
66
rb ["model" ] = llmReq .ResolvedTargetModel
66
67
requestBody , err = json .Marshal (rb )
67
68
if err != nil {
68
- klog .Errorf ( "Error marshaling request body: %v" , err )
69
+ klog .V ( logutil . DEFAULT ). ErrorS ( err , "Error marshaling request body" )
69
70
return nil , fmt .Errorf ("error marshaling request body: %v" , err )
70
71
}
71
- klog . V ( logutil . VERBOSE ). Infof ( "Updated body: %v " , string (requestBody ))
72
+ klogV . InfoS ( "Updated request body marshalled" , "body " , string (requestBody ))
72
73
}
73
74
74
75
targetPod , err := s .scheduler .Schedule (llmReq )
75
76
if err != nil {
76
77
return nil , fmt .Errorf ("failed to find target pod: %w" , err )
77
78
}
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 )
79
80
80
81
reqCtx .Model = llmReq .Model
81
82
reqCtx .ResolvedTargetModel = llmReq .ResolvedTargetModel
@@ -101,7 +102,7 @@ func (s *Server) HandleRequestBody(reqCtx *RequestContext, req *extProcPb.Proces
101
102
}
102
103
// Print headers for debugging
103
104
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 )
105
106
}
106
107
107
108
resp := & extProcPb.ProcessingResponse {
@@ -136,10 +137,9 @@ func (s *Server) HandleRequestBody(reqCtx *RequestContext, req *extProcPb.Proces
136
137
}
137
138
138
139
func HandleRequestHeaders (reqCtx * RequestContext , req * extProcPb.ProcessingRequest ) * extProcPb.ProcessingResponse {
139
- klog .V (logutil .VERBOSE ).Info ("Handling request headers ..." )
140
140
r := req .Request
141
141
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 )
143
143
144
144
resp := & extProcPb.ProcessingResponse {
145
145
Response : & extProcPb.ProcessingResponse_RequestHeaders {
0 commit comments