Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 96 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/api_server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ mmds = { path = "../mmds" }
seccompiler = { path = "../seccompiler" }
utils = { path = "../utils" }
vmm = { path = "../vmm" }
tracing = { version = "0.1.37", default-features = false, features = ["max_level_debug", "attributes"] }

[dev-dependencies]
libc = "0.2.117"
log = "0.4.19"
12 changes: 12 additions & 0 deletions src/api_server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ pub struct ApiServer {
}

impl ApiServer {
#[tracing::instrument(
level = "trace",
skip(api_request_sender, vmm_response_receiver, to_vmm_fd)
)]
/// Constructor for `ApiServer`.
///
/// Returns the newly formed `ApiServer`.
Expand All @@ -59,6 +63,10 @@ impl ApiServer {
}
}

#[tracing::instrument(
level = "trace",
skip(self, server, process_time_reporter, seccomp_filter, api_payload_limit)
)]
/// Runs the Api Server.
///
/// # Arguments
Expand Down Expand Up @@ -128,6 +136,7 @@ impl ApiServer {
}
}

#[tracing::instrument(level = "trace", skip(self, request, request_processing_start_us))]
/// Handles an API request received through the associated socket.
pub fn handle_request(
&mut self,
Expand Down Expand Up @@ -158,6 +167,7 @@ impl ApiServer {
}
}

#[tracing::instrument(level = "trace", skip(self, vmm_action, request_processing_start_us))]
fn serve_vmm_action_request(
&mut self,
vmm_action: Box<VmmAction>,
Expand Down Expand Up @@ -199,13 +209,15 @@ impl ApiServer {
response
}

#[tracing::instrument(level = "trace", skip(status, body))]
/// An HTTP response which also includes a body.
pub(crate) fn json_response<T: Into<String> + Debug>(status: StatusCode, body: T) -> Response {
let mut response = Response::new(Version::Http11, status);
response.set_body(Body::new(body.into()));
response
}

#[tracing::instrument(level = "trace", skip(msg))]
fn json_fault_message<T: AsRef<str> + serde::Serialize + Debug>(msg: T) -> String {
json!({ "fault_message": msg }).to_string()
}
Expand Down
Loading