@@ -29,8 +29,13 @@ pub(crate) static METRIC_GUEST_FUNC_DURATION: &str = "guest_call_duration_second
2929#[ cfg( feature = "function_call_metrics" ) ]
3030pub ( 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 {
0 commit comments