diff options
author | Aaron O'Mullan <aaron.omullan@gmail.com> | 2021-10-10 17:20:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-10 17:20:30 +0200 |
commit | 5a8a989b7815023f33a1e3183a55cc8999af5d98 (patch) | |
tree | d15619ed83a2965f17dc10a78c9072f34d393009 /core/ops_builtin.rs | |
parent | f2ac7ff23a2ae4925f4ca32ffd61c923c481ef4e (diff) |
refactor(metrics): move to core (#12386)
Avoids overhead of wrapping ops (and allocs when inspecting async-op futures)
Diffstat (limited to 'core/ops_builtin.rs')
-rw-r--r-- | core/ops_builtin.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/core/ops_builtin.rs b/core/ops_builtin.rs index 83f2e504a..c830f8eff 100644 --- a/core/ops_builtin.rs +++ b/core/ops_builtin.rs @@ -2,6 +2,7 @@ use crate::error::type_error; use crate::error::AnyError; use crate::include_js_files; use crate::op_sync; +use crate::ops_metrics::OpMetrics; use crate::resources::ResourceId; use crate::void_op_async; use crate::void_op_sync; @@ -32,6 +33,7 @@ pub(crate) fn init_builtins() -> Extension { "op_wasm_streaming_set_url", op_sync(op_wasm_streaming_set_url), ), + ("op_metrics", op_sync(op_metrics)), ("op_void_sync", void_op_sync()), ("op_void_async", void_op_async()), ]) @@ -158,3 +160,13 @@ pub fn op_wasm_streaming_set_url( Ok(()) } + +pub fn op_metrics( + state: &mut OpState, + _: (), + _: (), +) -> Result<(OpMetrics, Vec<OpMetrics>), AnyError> { + let aggregate = state.tracker.aggregate(); + let per_op = state.tracker.per_op(); + Ok((aggregate, per_op)) +} |