Skip to content

Commit eaee937

Browse files
committed
Replace hyperlight-specific metrics with metrics crate
Signed-off-by: Ludvig Liljenberg <[email protected]>
1 parent 3313081 commit eaee937

File tree

9 files changed

+816
-600
lines changed

9 files changed

+816
-600
lines changed

Cargo.lock

Lines changed: 707 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Justfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ clippy target=default-target: (check target)
5858
test target=default-target features="": (test-inprocess target) (test-seccomp target features)
5959
cargo test {{ if features =="" {''} else if features=="no-default-features" {"--no-default-features" } else {"--no-default-features -F " + features } }} --profile={{ if target == "debug" {"dev"} else { target } }}
6060
cargo test test_metrics {{ if features =="" {''} else if features=="no-default-features" {"--no-default-features" } else {"--no-default-features -F " + features } }} --profile={{ if target == "debug" {"dev"} else { target } }} -- --ignored
61-
cargo test test_gather_metrics {{ if features =="" {''} else if features=="no-default-features" {"--no-default-features" } else {"--no-default-features -F " + features } }} --profile={{ if target == "debug" {"dev"} else { target } }} -- --ignored
6261

6362
test-inprocess target=default-target:
6463
{{ if target == "debug" { "cargo test --features='inprocess'; cargo test test_metrics --features='inprocess' -- --ignored; cargo test test_gather_metrics --features='inprocess' -- --ignored" } else {"echo 'inprocess tests are not run for release builds'" } }}
@@ -83,4 +82,4 @@ bench target=default-target features="":
8382
bench-download os hypervisor tag="":
8483
gh release download {{ tag }} -D ./src/hyperlight_wasm/target/ -p benchmarks_{{ os }}_{{ hypervisor }}.tar.gz
8584
mkdir {{ mkdir-arg }} ./src/hyperlight_wasm/target/criterion
86-
tar -zxvf ./src/hyperlight_wasm/target/benchmarks_{{ os }}_{{ hypervisor }}.tar.gz -C ./src/hyperlight_wasm/target/criterion/ --strip-components=1
85+
tar -zxvf ./src/hyperlight_wasm/target/benchmarks_{{ os }}_{{ hypervisor }}.tar.gz -C ./src/hyperlight_wasm/target/criterion/ --strip-components=1

docs/observability.md

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,31 @@
22

33
hyperlight-wasm provides the following observability features:
44

5-
* [Metrics](#metrics) metrics are provided using Prometheus.
5+
* [Metrics](#metrics) metrics are provided using `metrics` crate.
66

77
## Metrics
88

9-
Hyperlight-wasm provides metrics using Prometheus. The metrics are registered using either the [default_registry](https://docs.rs/prometheus/latest/prometheus/fn.default_registry.html) or a registry instance provided by the host application.
109

11-
To provide a registry to hyperlight_wasm, use the `set_metrics_registry` function and pass a reference to a registry with `static` lifetime:
10+
The following metrics are provided and are enabled by default:
1211

13-
```rust
14-
use hyperlight_wasm::set_metrics_registry;
15-
use prometheus::Registry;
16-
use lazy_static::lazy_static;
12+
* `active_proto_wasm_sandboxes` - A gauge indicating the number of currently active proto wasm sandboxes
13+
* `active_wasm_sandboxes` - A gauge indicating the number of currently active wasm sandboxes
14+
* `active_loaded_wasm_sandboxes` - A gauge indicating the number of currently loaded wasm sandboxes
15+
* `proto_wasm_sandboxes_total` - A counter indicating the total number of proto wasm sandboxes created during the lifetime of the process
16+
* `wasm_sandboxes_total` - A counter indicating the total number of wasm sandboxes created during the lifetime of the process
17+
* `loaded_wasm_sandboxes_total` - A counter indicating the total number of loaded wasm sandboxes created during the lifetime of the process
18+
* `sandbox_loads_total` - A counter indicating how many times a wasm sandbox has been loaded into a loaded wasm sandbox during the lifetime of the process
19+
* `sandbox_unloads_total` - A counter indicating how many times a loaded wasm sandbox has been unloaded into a wasm sandbox during the lifetime of the process
1720

18-
lazy_static! {
19-
static ref REGISTRY: Registry = Registry::new();
20-
}
2121

22-
set_metrics_registry(&REGISTRY);
23-
```
22+
In addition, regular Hyperlight provides the following metrics:
2423

25-
The following metrics are provided and are enabled by default:
24+
* `guest_errors_total` - A counter indicating how many times a guest error has occured
25+
* `guest_cancellations_total` - The number of times guest execution has timed out
26+
27+
If cargo feature `function_call_metrics` is enabled:
2628

27-
* `hyperlight_guest_error_count` - a vector of counters that tracks the number of guest errors by code and message.
28-
* `hyperlight_number_of_cancelled_guest_execution` - a counter that tracks the number of guest executions that have been cancelled because the execution time exceeded the time allowed.
29-
* `current_number_of_wasm_sandboxes` - a gauge that tracks the current number of wasm sandboxes in this process.
30-
* `current_number_of_loaded_wasm_sandboxes` - a gauge that tracks the current number of loaded wasm sandboxes in this process.
31-
* `number_of_unloads_of_loaded_wasm_sandboxes` - a counter that tracks the number of times that unload_module has been called on a LoadedWasmSandbox.
32-
* `number_of_loads_of_wasm_sandboxes` - a counter that tracks the number of times that load_module has been called on a WasmSandbox.
33-
* `current_number_of_proto_wasm_sandboxes` - a gauge that tracks the current number of proto wasm sandboxes in this process.
34-
* `total_number_of_wasm_sandboxes` - a counter that tracks the total number of wasm sandboxes that have been created by this process.
35-
* `total_number_of_loaded_wasm_sandboxes` - a counter that tracks the total number of loaded wasm sandboxes that have been created by this process.
36-
* `total_number_of_proto_wasm_sandboxes` - a counter that tracks the total number of proto wasm sandboxes that have been created by this process.
37-
38-
The following metrics are provided and are enabled by default using the feature `function_call_metrics` but can be disabled:
39-
40-
* `hyperlight_guest_function_call_duration_microseconds` - a vector of histograms that tracks the execution time of guest functions in microseconds by function name. The histogram also tracks the number of calls to each function.
41-
* `hyperlight_host_function_calls_duration_microseconds` - a vector of histograms that tracks the execution time of host functions in microseconds by function name. The histogram also tracks the number of calls to each function.
29+
* `guest_call_duration_seconds` - Histogram for the execution time of guest function calls
30+
* `host_call_duration_seconds` - Histogram for the execution time of host function calls
4231

4332
There is an example of how to gather metrics in the [examples/metrics](../src/hyperlight_wasm/examples/metrics) directory.

src/hyperlight_wasm/Cargo.toml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,25 +34,23 @@ test = true
3434
hyperlight-host = { workspace = true }
3535
libc = { version = "0.2.171" }
3636
once_cell = "1.21.3"
37-
strum = "0.27"
3837
tracing = "0.1.27"
3938
log = "0.4.27"
4039
cfg-if = { version = "1" }
40+
metrics = "0.24.2"
4141

4242
[target.'cfg(windows)'.dependencies]
43-
windows = { version = "0.61", features = [
44-
"Win32_System_Threading",
45-
] }
43+
windows = { version = "0.61", features = ["Win32_System_Threading"] }
4644
page_size = "0.6.0"
4745

4846
[dev-dependencies]
4947
examples_common = { path = "../examples_common" }
5048
criterion = { version = "0.5.1", features = ["html_reports"] }
51-
lazy_static = "1.4.0"
52-
prometheus = "0.13.3"
5349
crossbeam-queue = "0.3"
5450
blake3 = "1.8"
5551
toml = "0.8.19"
52+
metrics-util = "0.19.1"
53+
metrics-exporter-prometheus = "0.17"
5654

5755
[build-dependencies]
5856
chrono = "0.4"

0 commit comments

Comments
 (0)