Skip to content

Commit 3d84e23

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

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ use hyperlight_guest_bin::host_comm::{
5353
use hyperlight_guest_bin::memory::malloc;
5454
use hyperlight_guest_bin::{MIN_STACK_ADDRESS, guest_logger};
5555
use log::{LevelFilter, error};
56+
use tracing::{Span, instrument};
5657

5758
extern crate hyperlight_guest;
5859

@@ -91,6 +92,7 @@ fn echo_float(function_call: &FunctionCall) -> Result<Vec<u8>> {
9192
}
9293
}
9394

95+
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
9496
fn print_output(message: &str) -> Result<Vec<u8>> {
9597
let res = call_host_function::<i32>(
9698
"HostPrint",
@@ -101,6 +103,7 @@ fn print_output(message: &str) -> Result<Vec<u8>> {
101103
Ok(get_flatbuffer_result(res))
102104
}
103105

106+
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
104107
fn simple_print_output(function_call: &FunctionCall) -> Result<Vec<u8>> {
105108
if let ParameterValue::String(message) = function_call.parameters.clone().unwrap()[0].clone() {
106109
print_output(&message)
@@ -883,6 +886,7 @@ fn exec_mapped_buffer(function_call: &FunctionCall) -> Result<Vec<u8>> {
883886
}
884887

885888
#[no_mangle]
889+
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
886890
pub extern "C" fn hyperlight_main() {
887891
let twenty_four_k_in_def = GuestFunctionDefinition::new(
888892
"24K_in_8K_out".to_string(),
@@ -1593,6 +1597,7 @@ fn fuzz_host_function(func: FunctionCall) -> Result<Vec<u8>> {
15931597
}
15941598

15951599
#[no_mangle]
1600+
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
15961601
pub fn guest_dispatch_function(function_call: FunctionCall) -> Result<Vec<u8>> {
15971602
// This test checks the stack behavior of the input/output buffer
15981603
// by calling the host before serializing the function call.

0 commit comments

Comments
 (0)