summaryrefslogtreecommitdiff
path: root/runtime/metrics.rs
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/metrics.rs')
-rw-r--r--runtime/metrics.rs28
1 files changed, 14 insertions, 14 deletions
diff --git a/runtime/metrics.rs b/runtime/metrics.rs
index b42e0c551..a80ec5e21 100644
--- a/runtime/metrics.rs
+++ b/runtime/metrics.rs
@@ -101,27 +101,27 @@ impl OpMetrics {
}
}
-use deno_core::BufVec;
use deno_core::Op;
use deno_core::OpFn;
-use deno_core::OpState;
-use std::cell::RefCell;
use std::collections::HashMap;
-use std::rc::Rc;
pub fn metrics_op(name: &'static str, op_fn: Box<OpFn>) -> Box<OpFn> {
- Box::new(move |op_state: Rc<RefCell<OpState>>, bufs: BufVec| -> Op {
+ Box::new(move |op_state, payload, buf| -> Op {
// TODOs:
// * The 'bytes' metrics seem pretty useless, especially now that the
// distinction between 'control' and 'data' buffers has become blurry.
// * Tracking completion of async ops currently makes us put the boxed
// future into _another_ box. Keeping some counters may not be expensive
// in itself, but adding a heap allocation for every metric seems bad.
- let mut buf_len_iter = bufs.iter().map(|buf| buf.len());
- let bytes_sent_control = buf_len_iter.next().unwrap_or(0);
- let bytes_sent_data = buf_len_iter.sum();
- let op = (op_fn)(op_state.clone(), bufs);
+ // TODO: remove this, doesn't make a ton of sense
+ let bytes_sent_control = 0;
+ let bytes_sent_data = match buf {
+ Some(ref b) => b.len(),
+ None => 0,
+ };
+
+ let op = (op_fn)(op_state.clone(), payload, buf);
let op_state_ = op_state.clone();
let mut s = op_state.borrow_mut();
@@ -138,17 +138,17 @@ pub fn metrics_op(name: &'static str, op_fn: Box<OpFn>) -> Box<OpFn> {
match op {
Op::Sync(buf) => {
- metrics.op_sync(bytes_sent_control, bytes_sent_data, buf.len());
+ metrics.op_sync(bytes_sent_control, bytes_sent_data, 0);
Op::Sync(buf)
}
Op::Async(fut) => {
metrics.op_dispatched_async(bytes_sent_control, bytes_sent_data);
let fut = fut
- .inspect(move |buf| {
+ .inspect(move |_resp| {
let mut s = op_state_.borrow_mut();
let runtime_metrics = s.borrow_mut::<RuntimeMetrics>();
let metrics = runtime_metrics.ops.get_mut(name).unwrap();
- metrics.op_completed_async(buf.len());
+ metrics.op_completed_async(0);
})
.boxed_local();
Op::Async(fut)
@@ -156,11 +156,11 @@ pub fn metrics_op(name: &'static str, op_fn: Box<OpFn>) -> Box<OpFn> {
Op::AsyncUnref(fut) => {
metrics.op_dispatched_async_unref(bytes_sent_control, bytes_sent_data);
let fut = fut
- .inspect(move |buf| {
+ .inspect(move |_resp| {
let mut s = op_state_.borrow_mut();
let runtime_metrics = s.borrow_mut::<RuntimeMetrics>();
let metrics = runtime_metrics.ops.get_mut(name).unwrap();
- metrics.op_completed_async_unref(buf.len());
+ metrics.op_completed_async_unref(0);
})
.boxed_local();
Op::AsyncUnref(fut)