summaryrefslogtreecommitdiff
path: root/runtime/worker.rs
diff options
context:
space:
mode:
authorMatt Mastracci <matthew@mastracci.com>2023-11-05 14:27:36 -0700
committerGitHub <noreply@github.com>2023-11-05 14:27:36 -0700
commit485fade0b6910e29557c6627d37985b47735bf8e (patch)
tree0f6c97c135c8a92226caecb363effe7eabf47936 /runtime/worker.rs
parent4530cd5f0d5e6acdbbb11a60eac711d47f274d3f (diff)
chore: migrate to new deno_core and metrics (#21057)
- Uses the new OpMetrics system for sync and async calls - Partial revert of #21048 as we moved Array.fromAsync upstream to deno_core
Diffstat (limited to 'runtime/worker.rs')
-rw-r--r--runtime/worker.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/runtime/worker.rs b/runtime/worker.rs
index 2e2910109..4775b474c 100644
--- a/runtime/worker.rs
+++ b/runtime/worker.rs
@@ -27,6 +27,7 @@ use deno_core::ModuleCode;
use deno_core::ModuleId;
use deno_core::ModuleLoader;
use deno_core::ModuleSpecifier;
+use deno_core::OpMetricsSummaryTracker;
use deno_core::RuntimeOptions;
use deno_core::SharedArrayBufferStore;
use deno_core::Snapshot;
@@ -324,6 +325,18 @@ impl MainWorker {
}
}
+ // Hook up the summary metrics if the user or subcommand requested them
+ let (op_summary_metrics, op_metrics_factory_fn) =
+ if options.bootstrap.enable_op_summary_metrics {
+ let op_summary_metrics = Rc::new(OpMetricsSummaryTracker::default());
+ (
+ Some(op_summary_metrics.clone()),
+ Some(op_summary_metrics.op_metrics_factory_fn(|_| true)),
+ )
+ } else {
+ (None, None)
+ };
+
extensions.extend(std::mem::take(&mut options.extensions));
#[cfg(all(feature = "include_js_files_for_snapshotting", feature = "dont_create_runtime_snapshot", not(feature = "__runtime_js_sources")))]
@@ -349,9 +362,14 @@ impl MainWorker {
inspector: options.maybe_inspector_server.is_some(),
is_main: true,
feature_checker: Some(options.feature_checker.clone()),
+ op_metrics_factory_fn,
..Default::default()
});
+ if let Some(op_summary_metrics) = op_summary_metrics {
+ js_runtime.op_state().borrow_mut().put(op_summary_metrics);
+ }
+
if let Some(server) = options.maybe_inspector_server.clone() {
server.register_inspector(
main_module.to_string(),