You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/hyperlight-metrics-logs-and-traces.md
+16-4Lines changed: 16 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -98,7 +98,7 @@ Hyperlight provides advanced observability features for guest code running insid
98
98
99
99
The following features are available for guest tracing:
100
100
-`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.
102
102
103
103
### Building a Guest with Tracing Support
104
104
@@ -111,17 +111,29 @@ just move-rust-guests debug
111
111
112
112
This will build the guest binaries with the `trace_guest` feature enabled and move them to the appropriate location for use by the host.
113
113
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
+
114
116
### Running a Hyperlight Example with Guest Tracing
115
117
116
118
Once the guest is built, you can run a Hyperlight example with guest tracing enabled. For example:
117
119
118
120
```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
120
122
```
121
123
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
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:
0 commit comments