@@ -42,13 +42,15 @@ pub(crate) struct ParsingInfo {
42
42
}
43
43
44
44
impl ParsingInfo {
45
+ #[ tracing:: instrument( level = "trace" , ret) ]
45
46
pub fn append_deprecation_message ( & mut self , message : & str ) {
46
47
match self . deprecation_message . as_mut ( ) {
47
48
None => self . deprecation_message = Some ( message. to_owned ( ) ) ,
48
49
Some ( s) => ( * s) . push_str ( message) ,
49
50
}
50
51
}
51
52
53
+ #[ tracing:: instrument( level = "trace" , ret) ]
52
54
pub fn take_deprecation_message ( & mut self ) -> Option < String > {
53
55
self . deprecation_message . take ( )
54
56
}
@@ -122,21 +124,25 @@ impl TryFrom<&Request> for ParsedRequest {
122
124
}
123
125
124
126
impl ParsedRequest {
127
+ #[ tracing:: instrument( level = "trace" , ret) ]
125
128
pub ( crate ) fn new ( action : RequestAction ) -> Self {
126
129
Self {
127
130
action,
128
131
parsing_info : Default :: default ( ) ,
129
132
}
130
133
}
131
-
134
+
135
+ #[ tracing:: instrument( level = "trace" , ret) ]
132
136
pub ( crate ) fn into_parts ( self ) -> ( RequestAction , ParsingInfo ) {
133
137
( self . action , self . parsing_info )
134
138
}
135
139
140
+ #[ tracing:: instrument( level = "trace" ) ]
136
141
pub ( crate ) fn parsing_info ( & mut self ) -> & mut ParsingInfo {
137
142
& mut self . parsing_info
138
143
}
139
144
145
+ #[ tracing:: instrument( level = "trace" , ret) ]
140
146
pub ( crate ) fn success_response_with_data < T > ( body_data : & T ) -> Response
141
147
where
142
148
T : ?Sized + Serialize + Debug ,
@@ -147,6 +153,7 @@ impl ParsedRequest {
147
153
response
148
154
}
149
155
156
+ #[ tracing:: instrument( level = "trace" , ret) ]
150
157
pub ( crate ) fn success_response_with_mmds_value ( body_data : & Value ) -> Response {
151
158
info ! ( "The request was executed successfully. Status code: 200 OK." ) ;
152
159
let mut response = Response :: new ( Version :: Http11 , StatusCode :: OK ) ;
@@ -158,6 +165,7 @@ impl ParsedRequest {
158
165
response
159
166
}
160
167
168
+ #[ tracing:: instrument( level = "trace" , ret) ]
161
169
pub ( crate ) fn convert_to_response (
162
170
request_outcome : & std:: result:: Result < VmmData , VmmActionError > ,
163
171
) -> Response {
@@ -207,6 +215,7 @@ impl ParsedRequest {
207
215
}
208
216
209
217
/// Helper function to avoid boiler-plate code.
218
+ #[ tracing:: instrument( level = "trace" , ret) ]
210
219
pub ( crate ) fn new_sync ( vmm_action : VmmAction ) -> ParsedRequest {
211
220
ParsedRequest :: new ( RequestAction :: Sync ( Box :: new ( vmm_action) ) )
212
221
}
@@ -216,6 +225,7 @@ impl ParsedRequest {
216
225
///
217
226
/// The `info` macro is used for logging.
218
227
#[ inline]
228
+ #[ tracing:: instrument( level = "trace" , ret) ]
219
229
fn log_received_api_request ( api_description : String ) {
220
230
info ! ( "The API server received a {}." , api_description) ;
221
231
}
@@ -227,6 +237,7 @@ fn log_received_api_request(api_description: String) {
227
237
/// * `method` - one of `GET`, `PATCH`, `PUT`
228
238
/// * `path` - path of the API request
229
239
/// * `body` - body of the API request
240
+ #[ tracing:: instrument( level = "trace" , ret) ]
230
241
fn describe ( method : Method , path : & str , body : Option < & Body > ) -> String {
231
242
match ( path, body) {
232
243
( "/mmds" , Some ( _) ) | ( _, None ) => format ! ( "{:?} request on {:?}" , method, path) ,
@@ -242,6 +253,7 @@ fn describe(method: Method, path: &str, body: Option<&Body>) -> String {
242
253
}
243
254
244
255
/// Generates a `GenericError` for each request method.
256
+ #[ tracing:: instrument( level = "trace" , ret) ]
245
257
pub ( crate ) fn method_to_error ( method : Method ) -> Result < ParsedRequest , Error > {
246
258
match method {
247
259
Method :: Get => Err ( Error :: Generic (
@@ -280,6 +292,7 @@ pub(crate) enum Error {
280
292
281
293
// It's convenient to turn errors into HTTP responses directly.
282
294
impl From < Error > for Response {
295
+ #[ tracing:: instrument( level = "trace" , ret) ]
283
296
fn from ( err : Error ) -> Self {
284
297
let msg = ApiServer :: json_fault_message ( format ! ( "{}" , err) ) ;
285
298
match err {
@@ -293,6 +306,7 @@ impl From<Error> for Response {
293
306
}
294
307
295
308
// This function is supposed to do id validation for requests.
309
+ #[ tracing:: instrument( level = "trace" , ret) ]
296
310
pub ( crate ) fn checked_id ( id : & str ) -> Result < & str , Error > {
297
311
// todo: are there any checks we want to do on id's?
298
312
// not allow them to be empty strings maybe?
@@ -325,6 +339,7 @@ pub mod tests {
325
339
use super :: * ;
326
340
327
341
impl PartialEq for ParsedRequest {
342
+ #[ tracing:: instrument( level = "trace" , ret) ]
328
343
fn eq ( & self , other : & ParsedRequest ) -> bool {
329
344
if self . parsing_info . deprecation_message != other. parsing_info . deprecation_message {
330
345
return false ;
@@ -339,13 +354,15 @@ pub mod tests {
339
354
}
340
355
}
341
356
357
+ #[ tracing:: instrument( level = "trace" , ret) ]
342
358
pub ( crate ) fn vmm_action_from_request ( req : ParsedRequest ) -> VmmAction {
343
359
match req. action {
344
360
RequestAction :: Sync ( vmm_action) => * vmm_action,
345
361
_ => panic ! ( "Invalid request" ) ,
346
362
}
347
363
}
348
364
365
+ #[ tracing:: instrument( level = "trace" , ret) ]
349
366
pub ( crate ) fn depr_action_from_req ( req : ParsedRequest , msg : Option < String > ) -> VmmAction {
350
367
let ( action_req, mut parsing_info) = req. into_parts ( ) ;
351
368
match action_req {
@@ -359,6 +376,7 @@ pub mod tests {
359
376
}
360
377
}
361
378
379
+ #[ tracing:: instrument( level = "trace" , ret) ]
362
380
fn http_response ( body : & str , status_code : i32 ) -> String {
363
381
let header = format ! (
364
382
"HTTP/1.1 {} \r \n Server: Firecracker API\r \n Connection: keep-alive\r \n " ,
@@ -378,6 +396,7 @@ pub mod tests {
378
396
}
379
397
}
380
398
399
+ #[ tracing:: instrument( level = "trace" , ret) ]
381
400
fn http_request ( request_type : & str , endpoint : & str , body : Option < & str > ) -> String {
382
401
let req_no_body = format ! (
383
402
"{} {} HTTP/1.1\r \n Content-Type: application/json\r \n " ,
0 commit comments