Skip to content

Commit 26a8954

Browse files
committed
Add documentation on how to use the tracing functionality
Signed-off-by: Doru Blânzeanu <[email protected]>
1 parent 593becc commit 26a8954

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

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

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,77 @@ 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+
The following features are available for guest tracing:
100+
- `trace_guest`: Enables tracing for guest code, capturing function calls and execution time.
101+
- `unwind_guest`: Enables stack unwinding for guest code, allowing you to capture stack traces.
102+
- `mem_profile`: Enables memory profiling for guest code, capturing memory allocations and usage.
103+
104+
### Building a Guest with Tracing Support
105+
106+
To build a guest with tracing enabled, use the following commands:
107+
108+
```bash
109+
just build-rust-guests debug trace_guest
110+
just move-rust-guests debug
111+
```
112+
113+
This will build the guest binaries with the `trace_guest` feature enabled and move them to the appropriate location for use by the host.
114+
115+
### Running a Hyperlight Example with Guest Tracing
116+
117+
Once the guest is built, you can run a Hyperlight example with guest tracing enabled. For example:
118+
119+
```bash
120+
cargo run --example hello-world --features trace_guest
121+
```
122+
123+
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+
125+
### Inspecting Guest Trace Files
126+
127+
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:
128+
129+
```bash
130+
cargo run -p trace_dump <path_to_guest_symbols> <trace_file_path> list_frames
131+
```
132+
133+
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.
134+
135+
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.
136+
137+
#### Example
138+
139+
```bash
140+
cargo run -p trace_dump ./src/tests/rust_guests/bin/debug/simpleguest ./trace/<UUID>.trace list_frames
141+
```
142+
143+
You can use additional features such as `unwind_guest` and `mem_profile` by enabling them during the build and run steps.
144+
145+
> **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.
146+
147+
## System Prerequisites for `trace_dump`
148+
149+
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:
150+
151+
- **glib-2.0** development files
152+
- Fedora/RHEL/CentOS:
153+
```bash
154+
sudo dnf install glib2-devel pkgconf-pkg-config
155+
```
156+
- **cairo** and **cairo-gobject** development files
157+
- Fedora/RHEL/CentOS:
158+
```bash
159+
sudo dnf install cairo-devel cairo-gobject-devel
160+
```
161+
- **pango** development files
162+
- Fedora/RHEL/CentOS:
163+
```bash
164+
sudo dnf install pango-devel
165+
```
166+
167+
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)