Skip to content

Commit 9218de5

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

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

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

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,72 @@ 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.
141+
142+
## System Prerequisites for `trace_dump`
143+
144+
To build and use the `trace_dump` crate and related guest tracing features, you must have the following system libraries and development tools installed on your system:
145+
146+
- **glib-2.0** development files
147+
- Fedora/RHEL/CentOS:
148+
```bash
149+
sudo dnf install glib2-devel pkgconf-pkg-config
150+
```
151+
- **cairo** and **cairo-gobject** development files
152+
- Fedora/RHEL/CentOS:
153+
```bash
154+
sudo dnf install cairo-devel cairo-gobject-devel
155+
```
156+
- **pango** development files
157+
- Fedora/RHEL/CentOS:
158+
```bash
159+
sudo dnf install pango-devel
160+
```
161+
162+
These libraries are required by Rust crates such as `glib-sys`, `cairo-sys-rs`, and `pango-sys`, which are dependencies of the tracing and visualization tools. If you encounter errors about missing `.pc` files (e.g., `glib-2.0.pc`, `cairo.pc`, `pango.pc`), ensure the corresponding `-devel` packages are installed.

0 commit comments

Comments
 (0)