@@ -41,13 +41,15 @@ pub(crate) struct ParsingInfo {
41
41
}
42
42
43
43
impl ParsingInfo {
44
+ #[ tracing:: instrument( level = "trace" , skip( self , message) ) ]
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" , skip( self ) ) ]
51
53
pub fn take_deprecation_message ( & mut self ) -> Option < String > {
52
54
self . deprecation_message . take ( )
53
55
}
@@ -61,6 +63,7 @@ pub(crate) struct ParsedRequest {
61
63
62
64
impl TryFrom < & Request > for ParsedRequest {
63
65
type Error = Error ;
66
+ #[ tracing:: instrument( level = "trace" , skip( request) ) ]
64
67
fn try_from ( request : & Request ) -> Result < Self , Self :: Error > {
65
68
let request_uri = request. uri ( ) . get_abs_path ( ) . to_string ( ) ;
66
69
log_received_api_request ( describe (
@@ -121,21 +124,25 @@ impl TryFrom<&Request> for ParsedRequest {
121
124
}
122
125
123
126
impl ParsedRequest {
127
+ #[ tracing:: instrument( level = "trace" , skip( action) ) ]
124
128
pub ( crate ) fn new ( action : RequestAction ) -> Self {
125
129
Self {
126
130
action,
127
131
parsing_info : Default :: default ( ) ,
128
132
}
129
133
}
130
134
135
+ #[ tracing:: instrument( level = "trace" , skip( self ) ) ]
131
136
pub ( crate ) fn into_parts ( self ) -> ( RequestAction , ParsingInfo ) {
132
137
( self . action , self . parsing_info )
133
138
}
134
139
140
+ #[ tracing:: instrument( level = "trace" , skip( self ) ) ]
135
141
pub ( crate ) fn parsing_info ( & mut self ) -> & mut ParsingInfo {
136
142
& mut self . parsing_info
137
143
}
138
144
145
+ #[ tracing:: instrument( level = "trace" , skip( body_data) ) ]
139
146
pub ( crate ) fn success_response_with_data < T > ( body_data : & T ) -> Response
140
147
where
141
148
T : ?Sized + Serialize + Debug ,
@@ -146,6 +153,7 @@ impl ParsedRequest {
146
153
response
147
154
}
148
155
156
+ #[ tracing:: instrument( level = "trace" , skip( body_data) ) ]
149
157
pub ( crate ) fn success_response_with_mmds_value ( body_data : & Value ) -> Response {
150
158
info ! ( "The request was executed successfully. Status code: 200 OK." ) ;
151
159
let mut response = Response :: new ( Version :: Http11 , StatusCode :: OK ) ;
@@ -157,6 +165,7 @@ impl ParsedRequest {
157
165
response
158
166
}
159
167
168
+ #[ tracing:: instrument( level = "trace" , skip( request_outcome) ) ]
160
169
pub ( crate ) fn convert_to_response (
161
170
request_outcome : & std:: result:: Result < VmmData , VmmActionError > ,
162
171
) -> Response {
@@ -205,12 +214,14 @@ impl ParsedRequest {
205
214
}
206
215
}
207
216
217
+ #[ tracing:: instrument( level = "trace" , skip( vmm_action) ) ]
208
218
/// Helper function to avoid boiler-plate code.
209
219
pub ( crate ) fn new_sync ( vmm_action : VmmAction ) -> ParsedRequest {
210
220
ParsedRequest :: new ( RequestAction :: Sync ( Box :: new ( vmm_action) ) )
211
221
}
212
222
}
213
223
224
+ #[ tracing:: instrument( level = "trace" , skip( api_description) ) ]
214
225
/// Helper function for writing the received API requests to the log.
215
226
///
216
227
/// The `info` macro is used for logging.
@@ -219,6 +230,7 @@ fn log_received_api_request(api_description: String) {
219
230
info ! ( "The API server received a {}." , api_description) ;
220
231
}
221
232
233
+ #[ tracing:: instrument( level = "trace" , skip( method, path, body) ) ]
222
234
/// Helper function for metric-logging purposes on API requests.
223
235
///
224
236
/// # Arguments
@@ -246,6 +258,7 @@ fn describe(method: Method, path: &str, body: Option<&Body>) -> String {
246
258
}
247
259
}
248
260
261
+ #[ tracing:: instrument( level = "trace" , skip( method, path, payload_value) ) ]
249
262
fn describe_with_body ( method : Method , path : & str , payload_value : & Body ) -> String {
250
263
format ! (
251
264
"{:?} request on {:?} with body {:?}" ,
@@ -257,6 +270,7 @@ fn describe_with_body(method: Method, path: &str, payload_value: &Body) -> Strin
257
270
)
258
271
}
259
272
273
+ #[ tracing:: instrument( level = "trace" , skip( method) ) ]
260
274
/// Generates a `GenericError` for each request method.
261
275
pub ( crate ) fn method_to_error ( method : Method ) -> Result < ParsedRequest , Error > {
262
276
match method {
@@ -296,6 +310,7 @@ pub(crate) enum Error {
296
310
297
311
// It's convenient to turn errors into HTTP responses directly.
298
312
impl From < Error > for Response {
313
+ #[ tracing:: instrument( level = "trace" , skip( err) ) ]
299
314
fn from ( err : Error ) -> Self {
300
315
let msg = ApiServer :: json_fault_message ( format ! ( "{}" , err) ) ;
301
316
match err {
@@ -309,6 +324,7 @@ impl From<Error> for Response {
309
324
}
310
325
311
326
// This function is supposed to do id validation for requests.
327
+ #[ tracing:: instrument( level = "trace" , skip( id) ) ]
312
328
pub ( crate ) fn checked_id ( id : & str ) -> Result < & str , Error > {
313
329
// todo: are there any checks we want to do on id's?
314
330
// not allow them to be empty strings maybe?
@@ -341,6 +357,7 @@ pub mod tests {
341
357
use super :: * ;
342
358
343
359
impl PartialEq for ParsedRequest {
360
+ #[ tracing:: instrument( level = "trace" , skip( self , other) ) ]
344
361
fn eq ( & self , other : & ParsedRequest ) -> bool {
345
362
if self . parsing_info . deprecation_message != other. parsing_info . deprecation_message {
346
363
return false ;
@@ -355,13 +372,15 @@ pub mod tests {
355
372
}
356
373
}
357
374
375
+ #[ tracing:: instrument( level = "trace" , skip( req) ) ]
358
376
pub ( crate ) fn vmm_action_from_request ( req : ParsedRequest ) -> VmmAction {
359
377
match req. action {
360
378
RequestAction :: Sync ( vmm_action) => * vmm_action,
361
379
_ => panic ! ( "Invalid request" ) ,
362
380
}
363
381
}
364
382
383
+ #[ tracing:: instrument( level = "trace" , skip( req, msg) ) ]
365
384
pub ( crate ) fn depr_action_from_req ( req : ParsedRequest , msg : Option < String > ) -> VmmAction {
366
385
let ( action_req, mut parsing_info) = req. into_parts ( ) ;
367
386
match action_req {
@@ -375,6 +394,7 @@ pub mod tests {
375
394
}
376
395
}
377
396
397
+ #[ tracing:: instrument( level = "trace" , skip( body, status_code) ) ]
378
398
fn http_response ( body : & str , status_code : i32 ) -> String {
379
399
let header = format ! (
380
400
"HTTP/1.1 {} \r \n Server: Firecracker API\r \n Connection: keep-alive\r \n " ,
@@ -394,6 +414,7 @@ pub mod tests {
394
414
}
395
415
}
396
416
417
+ #[ tracing:: instrument( level = "trace" , skip( request_type, endpoint, body) ) ]
397
418
fn http_request ( request_type : & str , endpoint : & str , body : Option < & str > ) -> String {
398
419
let req_no_body = format ! (
399
420
"{} {} HTTP/1.1\r \n Content-Type: application/json\r \n " ,
0 commit comments