@@ -29,8 +29,13 @@ pub(crate) static METRIC_GUEST_FUNC_DURATION: &str = "guest_call_duration_second
29
29
#[ cfg( feature = "function_call_metrics" ) ]
30
30
pub ( crate ) static METRIC_HOST_FUNC_DURATION : & str = "host_call_duration_seconds" ;
31
31
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 > (
34
39
#[ allow( unused_variables) ] name : & str ,
35
40
f : F ,
36
41
) -> T {
@@ -51,8 +56,13 @@ pub(crate) fn time_and_emit_guest_call<T, F: FnOnce() -> T>(
51
56
}
52
57
}
53
58
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 > (
56
66
#[ allow( unused_variables) ] name : & str ,
57
67
f : F ,
58
68
) -> T {
0 commit comments