Skip to content

Commit 4ac490c

Browse files
committed
[trace-guest] add spans in simpleguest sample
Signed-off-by: Doru Blânzeanu <[email protected]>
1 parent 7613202 commit 4ac490c

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

src/tests/rust_guests/simpleguest/Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/tests/rust_guests/simpleguest/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ hyperlight-guest-bin = { path = "../../../hyperlight_guest_bin" }
99
hyperlight-common = { path = "../../../hyperlight_common", default-features = false }
1010
hyperlight-guest-tracing = { path = "../../../hyperlight_guest_tracing" }
1111
log = {version = "0.4", default-features = false }
12+
tracing = { version = "0.1.41", default-features = false, features = ["attributes"] }
1213

1314
[features]
1415
default = []

src/tests/rust_guests/simpleguest/src/main.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ use hyperlight_guest_bin::host_comm::{
5151
use hyperlight_guest_bin::memory::malloc;
5252
use hyperlight_guest_bin::{MIN_STACK_ADDRESS, guest_logger};
5353
use log::{LevelFilter, error};
54+
use tracing::{Span, instrument};
5455

5556
extern crate hyperlight_guest;
5657

@@ -89,6 +90,7 @@ fn echo_float(function_call: &FunctionCall) -> Result<Vec<u8>> {
8990
}
9091
}
9192

93+
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
9294
fn print_output(message: &str) -> Result<Vec<u8>> {
9395
let res = call_host_function::<i32>(
9496
"HostPrint",
@@ -99,6 +101,7 @@ fn print_output(message: &str) -> Result<Vec<u8>> {
99101
Ok(get_flatbuffer_result(res))
100102
}
101103

104+
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
102105
fn simple_print_output(function_call: &FunctionCall) -> Result<Vec<u8>> {
103106
if let ParameterValue::String(message) = function_call.parameters.clone().unwrap()[0].clone() {
104107
print_output(&message)
@@ -865,6 +868,7 @@ fn exec_mapped_buffer(function_call: &FunctionCall) -> Result<Vec<u8>> {
865868
}
866869

867870
#[no_mangle]
871+
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
868872
pub extern "C" fn hyperlight_main() {
869873
let twenty_four_k_in_def = GuestFunctionDefinition::new(
870874
"24K_in_8K_out".to_string(),
@@ -1321,6 +1325,7 @@ pub extern "C" fn hyperlight_main() {
13211325
}
13221326

13231327
#[no_mangle]
1328+
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
13241329
pub fn guest_dispatch_function(function_call: FunctionCall) -> Result<Vec<u8>> {
13251330
// This test checks the stack behavior of the input/output buffer
13261331
// by calling the host before serializing the function call.
@@ -1366,6 +1371,7 @@ pub fn guest_dispatch_function(function_call: FunctionCall) -> Result<Vec<u8>> {
13661371
}
13671372

13681373
// Interprets the given guest function call as a host function call and dispatches it to the host.
1374+
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
13691375
fn fuzz_host_function(func: FunctionCall) -> Result<Vec<u8>> {
13701376
let mut params = func.parameters.unwrap();
13711377
// first parameter must be string (the name of the host function to call)

0 commit comments

Comments
 (0)