summaryrefslogtreecommitdiff
path: root/runtime/ops
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/ops')
-rw-r--r--runtime/ops/io.rs4
-rw-r--r--runtime/ops/mod.rs4
-rw-r--r--runtime/ops/plugin.rs11
-rw-r--r--runtime/ops/runtime.rs27
-rw-r--r--runtime/ops/timers.rs2
5 files changed, 23 insertions, 25 deletions
diff --git a/runtime/ops/io.rs b/runtime/ops/io.rs
index 2ac8e1b78..bda8a51cb 100644
--- a/runtime/ops/io.rs
+++ b/runtime/ops/io.rs
@@ -105,8 +105,8 @@ lazy_static! {
}
pub fn init(rt: &mut JsRuntime) {
- rt.register_op("op_read", metrics_op(minimal_op(op_read)));
- rt.register_op("op_write", metrics_op(minimal_op(op_write)));
+ rt.register_op("op_read", metrics_op("op_read", minimal_op(op_read)));
+ rt.register_op("op_write", metrics_op("op_write", minimal_op(op_write)));
super::reg_json_async(rt, "op_shutdown", op_shutdown);
}
diff --git a/runtime/ops/mod.rs b/runtime/ops/mod.rs
index 3ead7efa2..e5dba723a 100644
--- a/runtime/ops/mod.rs
+++ b/runtime/ops/mod.rs
@@ -48,7 +48,7 @@ pub fn reg_json_async<F, V, R, RV>(
R: Future<Output = Result<RV, AnyError>> + 'static,
RV: Serialize,
{
- rt.register_op(name, metrics_op(json_op_async(op_fn)));
+ rt.register_op(name, metrics_op(name, json_op_async(op_fn)));
}
pub fn reg_json_sync<F, V, R>(rt: &mut JsRuntime, name: &'static str, op_fn: F)
@@ -57,7 +57,7 @@ where
V: DeserializeOwned,
R: Serialize,
{
- rt.register_op(name, metrics_op(json_op_sync(op_fn)));
+ rt.register_op(name, metrics_op(name, json_op_sync(op_fn)));
}
/// `UnstableChecker` is a struct so it can be placed inside `GothamState`;
diff --git a/runtime/ops/plugin.rs b/runtime/ops/plugin.rs
index e972df046..424b1dca0 100644
--- a/runtime/ops/plugin.rs
+++ b/runtime/ops/plugin.rs
@@ -126,10 +126,13 @@ impl<'a> plugin_api::Interface for PluginInterface<'a> {
_ => unreachable!(),
}
};
- self
- .state
- .op_table
- .register_op(name, metrics_op(Box::new(plugin_op_fn)))
+ self.state.op_table.register_op(
+ name,
+ metrics_op(
+ Box::leak(Box::new(name.to_string())),
+ Box::new(plugin_op_fn),
+ ),
+ )
}
}
diff --git a/runtime/ops/runtime.rs b/runtime/ops/runtime.rs
index 77abc45b7..a2f377bed 100644
--- a/runtime/ops/runtime.rs
+++ b/runtime/ops/runtime.rs
@@ -1,6 +1,7 @@
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
-use crate::metrics::Metrics;
+use crate::metrics::RuntimeMetrics;
+use crate::ops::UnstableChecker;
use crate::permissions::Permissions;
use deno_core::error::AnyError;
use deno_core::serde_json;
@@ -42,21 +43,15 @@ fn op_metrics(
_args: Value,
_zero_copy: &mut [ZeroCopyBuf],
) -> Result<Value, AnyError> {
- let m = state.borrow::<Metrics>();
-
- Ok(json!({
- "opsDispatched": m.ops_dispatched,
- "opsDispatchedSync": m.ops_dispatched_sync,
- "opsDispatchedAsync": m.ops_dispatched_async,
- "opsDispatchedAsyncUnref": m.ops_dispatched_async_unref,
- "opsCompleted": m.ops_completed,
- "opsCompletedSync": m.ops_completed_sync,
- "opsCompletedAsync": m.ops_completed_async,
- "opsCompletedAsyncUnref": m.ops_completed_async_unref,
- "bytesSentControl": m.bytes_sent_control,
- "bytesSentData": m.bytes_sent_data,
- "bytesReceived": m.bytes_received
- }))
+ let m = state.borrow::<RuntimeMetrics>();
+ let combined = m.combined_metrics();
+ let unstable_checker = state.borrow::<UnstableChecker>();
+ let maybe_ops = if unstable_checker.unstable {
+ Some(&m.ops)
+ } else {
+ None
+ };
+ Ok(json!({ "combined": combined, "ops": maybe_ops }))
}
pub fn ppid() -> Value {
diff --git a/runtime/ops/timers.rs b/runtime/ops/timers.rs
index a00b04ed0..783395cad 100644
--- a/runtime/ops/timers.rs
+++ b/runtime/ops/timers.rs
@@ -81,7 +81,7 @@ pub fn init(rt: &mut deno_core::JsRuntime) {
super::reg_json_sync(rt, "op_global_timer_stop", op_global_timer_stop);
super::reg_json_sync(rt, "op_global_timer_start", op_global_timer_start);
super::reg_json_async(rt, "op_global_timer", op_global_timer);
- rt.register_op("op_now", metrics_op(minimal_op(op_now)));
+ rt.register_op("op_now", metrics_op("op_now", minimal_op(op_now)));
super::reg_json_sync(rt, "op_sleep_sync", op_sleep_sync);
}