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/01_core.js | |
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/01_core.js')
-rw-r--r-- | core/01_core.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/core/01_core.js b/core/01_core.js index e1b0529f7..24b844453 100644 --- a/core/01_core.js +++ b/core/01_core.js @@ -12,8 +12,10 @@ Map, Array, ArrayPrototypeFill, + ArrayPrototypeMap, ErrorCaptureStackTrace, Promise, + ObjectEntries, ObjectFreeze, ObjectFromEntries, MapPrototypeGet, @@ -152,6 +154,15 @@ opSync("op_print", str, isErr); } + function metrics() { + const [aggregate, perOps] = opSync("op_metrics"); + aggregate.ops = ObjectFromEntries(ArrayPrototypeMap( + ObjectEntries(opsCache), + ([opName, opId]) => [opName, perOps[opId]], + )); + return aggregate; + } + // Some "extensions" rely on "BadResource" and "Interrupted" errors in the // JS code (eg. "deno_net") so they are provided in "Deno.core" but later // reexported on "Deno.errors" @@ -178,6 +189,7 @@ tryClose, print, resources, + metrics, registerErrorBuilder, registerErrorClass, opresolve, |