Skip to content

Commit ccaa14e

Browse files
committed
update tracing docs
Signed-off-by: Doru Blânzeanu <[email protected]>
1 parent 426dcfb commit ccaa14e

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

docs/hyperlight-metrics-logs-and-traces.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Hyperlight provides advanced observability features for guest code running insid
9898

9999
The following features are available for guest tracing:
100100
- `trace_guest`: Enables tracing for guest code, capturing function calls and execution time.
101-
- `mem_profile`: Enables memory profiling for guest code with stack uwinding, capturing memory allocations and usage.
101+
- `mem_profile`: Enables memory profiling for guest code with stack unwinding, capturing memory allocations and usage.
102102

103103
### Building a Guest with Tracing Support
104104

@@ -111,17 +111,29 @@ just move-rust-guests debug
111111

112112
This will build the guest binaries with the `trace_guest` feature enabled and move them to the appropriate location for use by the host.
113113

114+
**NOTE**: To enable the tracing in your application you need to use the `trace_guest` feature on the `hyperlight-guest-bin` and `hyperlight-guest` crates.
115+
114116
### Running a Hyperlight Example with Guest Tracing
115117

116118
Once the guest is built, you can run a Hyperlight example with guest tracing enabled. For example:
117119

118120
```bash
119-
cargo run --example hello-world --features trace_guest
121+
RUST_LOG="info,hyperlight_host::sandbox=info,hyperlight_guest=trace,hyperlight_guest_bin=trace" cargo run --example tracing-otlp --features trace_guest
120122
```
121123

122-
This will execute the `hello-world` example, loading the guest with tracing enabled. During execution, trace data will be collected and written to a file in the `trace` directory.
124+
This will execute the `tracing-otlp` example, loading the guest with tracing enabled.
125+
During execution, trace data will be collected on the host and exported as opentelemetry spans/events.
126+
127+
You can set up a collector to gather all the traces and inspect the traces from both host and guests.
128+
129+
Due to the nature of execution inside a Sandbox, on a call basis, the guest tracing sets up a stack of spans to keep track of the correct parents for the incoming
130+
guest spans.
131+
We start with `call-to-guest` which contains all the spans coming from a guest. Additionally, for each exit into the host, we add another layer marking it with
132+
a `call-to-host` span to follow the execution in the host and correctly set it as a child of the active span in the guest.
133+
This logic simulates the propagation of Opentelemetry context that is usually done between two services, but cannot be done here seamlessly because the guest side
134+
runs `no_std` which `opentelemetry` doesn't know.
123135

124-
### Inspecting Guest Trace Files
136+
### Inspecting Guest memory Trace Files (for mem_profile)
125137

126138
To inspect the trace file generated by the guest, use the `trace_dump` crate. You will need the path to the guest symbols and the trace file. Run the following command:
127139

0 commit comments

Comments
 (0)