2019-08-14 11:03:02 -04:00
|
|
|
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
2019-08-26 08:50:21 -04:00
|
|
|
use super::dispatch_json::{JsonOp, Value};
|
2019-08-14 11:03:02 -04:00
|
|
|
use crate::state::ThreadSafeState;
|
|
|
|
use deno::*;
|
2019-08-26 08:50:21 -04:00
|
|
|
use std::sync::atomic::Ordering;
|
2019-08-14 11:03:02 -04:00
|
|
|
|
|
|
|
pub fn op_metrics(
|
|
|
|
state: &ThreadSafeState,
|
2019-08-26 08:50:21 -04:00
|
|
|
_args: Value,
|
|
|
|
_zero_copy: Option<PinnedBuf>,
|
|
|
|
) -> Result<JsonOp, ErrBox> {
|
|
|
|
let m = &state.metrics;
|
2019-08-14 11:03:02 -04:00
|
|
|
|
2019-08-26 08:50:21 -04:00
|
|
|
Ok(JsonOp::Sync(json!({
|
|
|
|
"opsDispatched": m.ops_dispatched.load(Ordering::SeqCst) as u64,
|
|
|
|
"opsCompleted": m.ops_completed.load(Ordering::SeqCst) as u64,
|
|
|
|
"bytesSentControl": m.bytes_sent_control.load(Ordering::SeqCst) as u64,
|
|
|
|
"bytesSentData": m.bytes_sent_data.load(Ordering::SeqCst) as u64,
|
|
|
|
"bytesReceived": m.bytes_received.load(Ordering::SeqCst) as u64
|
|
|
|
})))
|
2019-08-14 11:03:02 -04:00
|
|
|
}
|