Skip to content

Commit ff4adb6

Browse files
committed
Add documentation on how to use the tracing functionality
Signed-off-by: Doru Blânzeanu <dblnz@pm.me>
1 parent a503449 commit ff4adb6

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

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

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,50 @@ NOTE: when running this on windows that this is a linux container, so you will n
9191
```
9292

9393
Once the container or the exe is running, the trace output can be viewed in the jaeger UI at [http://localhost:16686/search](http://localhost:16686/search).
94+
95+
## Guest Tracing, Unwinding, and Memory Profiling
96+
97+
Hyperlight provides advanced observability features for guest code running inside micro virtual machines. You can enable guest-side tracing, stack unwinding, and memory profiling using the `trace_guest`, `unwind_guest`, and `mem_profile` features. This section explains how to build, run, and inspect guest traces.
98+
99+
### Building a Guest with Tracing Support
100+
101+
To build a guest with tracing enabled, use the following commands:
102+
103+
```bash
104+
just build-rust-guests debug trace_guest
105+
just move-rust-guests debug
106+
```
107+
108+
This will build the guest binaries with the `trace_guest` feature enabled and move them to the appropriate location for use by the host.
109+
110+
### Running a Hyperlight Example with Guest Tracing
111+
112+
Once the guest is built, you can run a Hyperlight example with guest tracing enabled. For example:
113+
114+
```bash
115+
cargo run --example hello-world --features trace_guest
116+
```
117+
118+
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.
119+
120+
### Inspecting Guest Trace Files
121+
122+
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:
123+
124+
```bash
125+
cargo run -p trace_dump <path_to_guest_symbols> <trace_file_path> list_frames
126+
```
127+
128+
Replace `<path_to_guest_symbols>` with the path to the guest binary or symbol file, and `<trace_file_path>` with the path to the trace file in the `trace` directory.
129+
130+
This command will list the stack frames and tracing information captured during guest execution, allowing you to analyze guest behavior, stack traces, and memory usage.
131+
132+
#### Example
133+
134+
```bash
135+
cargo run -p trace_dump ./src/tests/rust_guests/bin/debug/simpleguest ./trace/<UUID>.trace list_frames
136+
```
137+
138+
You can use additional features such as `unwind_guest` and `mem_profile` by enabling them during the build and run steps. Refer to the guest and host documentation for more details on these features.
139+
140+
> **Note:** Make sure to follow the build and run steps in order, and ensure that the guest binaries are up to date before running the host example.

0 commit comments

Comments
 (0)