@@ -41,13 +41,15 @@ pub(crate) struct ParsingInfo {
41
41
}
42
42
43
43
impl ParsingInfo {
44
+ #[ tracing:: instrument( level = "trace" , ret) ]
44
45
pub fn append_deprecation_message ( & mut self , message : & str ) {
45
46
match self . deprecation_message . as_mut ( ) {
46
47
None => self . deprecation_message = Some ( message. to_owned ( ) ) ,
47
48
Some ( s) => ( * s) . push_str ( message) ,
48
49
}
49
50
}
50
51
52
+ #[ tracing:: instrument( level = "trace" , ret) ]
51
53
pub fn take_deprecation_message ( & mut self ) -> Option < String > {
52
54
self . deprecation_message . take ( )
53
55
}
@@ -121,21 +123,25 @@ impl TryFrom<&Request> for ParsedRequest {
121
123
}
122
124
123
125
impl ParsedRequest {
126
+ #[ tracing:: instrument( level = "trace" , ret) ]
124
127
pub ( crate ) fn new ( action : RequestAction ) -> Self {
125
128
Self {
126
129
action,
127
130
parsing_info : Default :: default ( ) ,
128
131
}
129
132
}
130
133
134
+ #[ tracing:: instrument( level = "trace" , ret) ]
131
135
pub ( crate ) fn into_parts ( self ) -> ( RequestAction , ParsingInfo ) {
132
136
( self . action , self . parsing_info )
133
137
}
134
138
139
+ #[ tracing:: instrument( level = "trace" ) ]
135
140
pub ( crate ) fn parsing_info ( & mut self ) -> & mut ParsingInfo {
136
141
& mut self . parsing_info
137
142
}
138
143
144
+ #[ tracing:: instrument( level = "trace" , ret) ]
139
145
pub ( crate ) fn success_response_with_data < T > ( body_data : & T ) -> Response
140
146
where
141
147
T : ?Sized + Serialize + Debug ,
@@ -146,6 +152,7 @@ impl ParsedRequest {
146
152
response
147
153
}
148
154
155
+ #[ tracing:: instrument( level = "trace" , ret) ]
149
156
pub ( crate ) fn success_response_with_mmds_value ( body_data : & Value ) -> Response {
150
157
info ! ( "The request was executed successfully. Status code: 200 OK." ) ;
151
158
let mut response = Response :: new ( Version :: Http11 , StatusCode :: OK ) ;
@@ -157,6 +164,7 @@ impl ParsedRequest {
157
164
response
158
165
}
159
166
167
+ #[ tracing:: instrument( level = "trace" , ret) ]
160
168
pub ( crate ) fn convert_to_response (
161
169
request_outcome : & std:: result:: Result < VmmData , VmmActionError > ,
162
170
) -> Response {
@@ -206,6 +214,7 @@ impl ParsedRequest {
206
214
}
207
215
208
216
/// Helper function to avoid boiler-plate code.
217
+ #[ tracing:: instrument( level = "trace" , ret) ]
209
218
pub ( crate ) fn new_sync ( vmm_action : VmmAction ) -> ParsedRequest {
210
219
ParsedRequest :: new ( RequestAction :: Sync ( Box :: new ( vmm_action) ) )
211
220
}
@@ -215,6 +224,7 @@ impl ParsedRequest {
215
224
///
216
225
/// The `info` macro is used for logging.
217
226
#[ inline]
227
+ #[ tracing:: instrument( level = "trace" , ret) ]
218
228
fn log_received_api_request ( api_description : String ) {
219
229
info ! ( "The API server received a {}." , api_description) ;
220
230
}
@@ -226,6 +236,7 @@ fn log_received_api_request(api_description: String) {
226
236
/// * `method` - one of `GET`, `PATCH`, `PUT`
227
237
/// * `path` - path of the API request
228
238
/// * `body` - body of the API request
239
+ #[ tracing:: instrument( level = "trace" , ret) ]
229
240
fn describe ( method : Method , path : & str , body : Option < & Body > ) -> String {
230
241
match ( path, body) {
231
242
( "/mmds" , Some ( _) ) | ( _, None ) => format ! ( "{:?} request on {:?}" , method, path) ,
@@ -246,6 +257,7 @@ fn describe_with_body(method: Method, path: &str, payload_value: &Body) -> Strin
246
257
}
247
258
248
259
/// Generates a `GenericError` for each request method.
260
+ #[ tracing:: instrument( level = "trace" , ret) ]
249
261
pub ( crate ) fn method_to_error ( method : Method ) -> Result < ParsedRequest , Error > {
250
262
match method {
251
263
Method :: Get => Err ( Error :: Generic (
@@ -284,6 +296,7 @@ pub(crate) enum Error {
284
296
285
297
// It's convenient to turn errors into HTTP responses directly.
286
298
impl From < Error > for Response {
299
+ #[ tracing:: instrument( level = "trace" , ret) ]
287
300
fn from ( err : Error ) -> Self {
288
301
let msg = ApiServer :: json_fault_message ( format ! ( "{}" , err) ) ;
289
302
match err {
@@ -297,6 +310,7 @@ impl From<Error> for Response {
297
310
}
298
311
299
312
// This function is supposed to do id validation for requests.
313
+ #[ tracing:: instrument( level = "trace" , ret) ]
300
314
pub ( crate ) fn checked_id ( id : & str ) -> Result < & str , Error > {
301
315
// todo: are there any checks we want to do on id's?
302
316
// not allow them to be empty strings maybe?
@@ -329,6 +343,7 @@ pub mod tests {
329
343
use super :: * ;
330
344
331
345
impl PartialEq for ParsedRequest {
346
+ #[ tracing:: instrument( level = "trace" , ret) ]
332
347
fn eq ( & self , other : & ParsedRequest ) -> bool {
333
348
if self . parsing_info . deprecation_message != other. parsing_info . deprecation_message {
334
349
return false ;
@@ -343,13 +358,15 @@ pub mod tests {
343
358
}
344
359
}
345
360
361
+ #[ tracing:: instrument( level = "trace" , ret) ]
346
362
pub ( crate ) fn vmm_action_from_request ( req : ParsedRequest ) -> VmmAction {
347
363
match req. action {
348
364
RequestAction :: Sync ( vmm_action) => * vmm_action,
349
365
_ => panic ! ( "Invalid request" ) ,
350
366
}
351
367
}
352
368
369
+ #[ tracing:: instrument( level = "trace" , ret) ]
353
370
pub ( crate ) fn depr_action_from_req ( req : ParsedRequest , msg : Option < String > ) -> VmmAction {
354
371
let ( action_req, mut parsing_info) = req. into_parts ( ) ;
355
372
match action_req {
@@ -363,6 +380,7 @@ pub mod tests {
363
380
}
364
381
}
365
382
383
+ #[ tracing:: instrument( level = "trace" , ret) ]
366
384
fn http_response ( body : & str , status_code : i32 ) -> String {
367
385
let header = format ! (
368
386
"HTTP/1.1 {} \r \n Server: Firecracker API\r \n Connection: keep-alive\r \n " ,
@@ -382,6 +400,7 @@ pub mod tests {
382
400
}
383
401
}
384
402
403
+ #[ tracing:: instrument( level = "trace" , ret) ]
385
404
fn http_request ( request_type : & str , endpoint : & str , body : Option < & str > ) -> String {
386
405
let req_no_body = format ! (
387
406
"{} {} HTTP/1.1\r \n Content-Type: application/json\r \n " ,
0 commit comments