Skip to content

Commit 047baf8

Browse files
committed
pr feedback
Signed-off-by: Ludvig Liljenberg <[email protected]>
1 parent 1cc9f83 commit 047baf8

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

Diff for: src/hyperlight_host/src/hypervisor/hypervisor_handler.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ impl HypervisorHandler {
433433
.lock
434434
.try_read();
435435

436-
let res = crate::metrics::time_and_emit_guest_call(
436+
let res = crate::metrics::maybe_time_and_emit_guest_call(
437437
&function_name,
438438
|| {
439439
hv.dispatch_call_from_host(

Diff for: src/hyperlight_host/src/metrics/mod.rs

+14-4
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,13 @@ pub(crate) static METRIC_GUEST_FUNC_DURATION: &str = "guest_call_duration_second
2929
#[cfg(feature = "function_call_metrics")]
3030
pub(crate) static METRIC_HOST_FUNC_DURATION: &str = "host_call_duration_seconds";
3131

32-
/// Utility function to emit a guest call duration metric
33-
pub(crate) fn time_and_emit_guest_call<T, F: FnOnce() -> T>(
32+
/// If the the `function_call_metrics` feature is enabled, this function measures
33+
/// the time it takes to execute the given closure, and will then emit a guest call metric
34+
/// with the given function name.
35+
///
36+
/// If the feature is not enabled, the given closure is executed without any additional metrics being emitted,
37+
/// and the result of the closure is returned directly.
38+
pub(crate) fn maybe_time_and_emit_guest_call<T, F: FnOnce() -> T>(
3439
#[allow(unused_variables)] name: &str,
3540
f: F,
3641
) -> T {
@@ -51,8 +56,13 @@ pub(crate) fn time_and_emit_guest_call<T, F: FnOnce() -> T>(
5156
}
5257
}
5358

54-
/// Utility function to emit a host call duration metric
55-
pub(crate) fn time_and_emit_host_call<T, F: FnOnce() -> T>(
59+
/// If the the `function_call_metrics` feature is enabled, this function measures
60+
/// the time it takes to execute the given closure, and will then emit a host call metric
61+
/// with the given function name.
62+
///
63+
/// If the feature is not enabled, the given closure is executed without any additional metrics being emitted,
64+
/// and the result of the closure is returned directly.
65+
pub(crate) fn maybe_time_and_emit_host_call<T, F: FnOnce() -> T>(
5666
#[allow(unused_variables)] name: &str,
5767
f: F,
5868
) -> T {

Diff for: src/hyperlight_host/src/sandbox/host_funcs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ fn call_host_func_impl(
181181
seccompiler::apply_filter(&seccomp_filter)?;
182182
}
183183

184-
crate::metrics::time_and_emit_host_call(name, || func.call(args))
184+
crate::metrics::maybe_time_and_emit_host_call(name, || func.call(args))
185185
}
186186

187187
cfg_if::cfg_if! {

0 commit comments

Comments
 (0)