1
1
mirror of https://github.com/wez/wezterm.git synced 2024-07-14 17:40:26 +03:00

update metrics to latest version (0.22)

This commit is contained in:
Wez Furlong 2024-05-13 09:29:54 -07:00
parent 281b6e2740
commit 6c890c3995
No known key found for this signature in database
GPG Key ID: 7A7F66A31EC9B387
24 changed files with 56 additions and 72 deletions

16
Cargo.lock generated
View File

@ -3284,26 +3284,14 @@ dependencies = [
[[package]]
name = "metrics"
version = "0.21.1"
version = "0.22.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fde3af1a009ed76a778cb84fdef9e7dbbdf5775ae3e4cc1f434a6a307f6f76c5"
checksum = "2be3cbd384d4e955b231c895ce10685e3d8260c5ccffae898c96c723b0772835"
dependencies = [
"ahash",
"metrics-macros",
"portable-atomic",
]
[[package]]
name = "metrics-macros"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38b4faf00617defe497754acde3024865bc143d44a86799b24e191ecff91354f"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.63",
]
[[package]]
name = "mime"
version = "0.3.17"

View File

@ -12,7 +12,7 @@ anyhow = "1.0"
config = { path = "../config" }
leb128 = "0.2"
log = "0.4"
metrics = "0.21"
metrics = "0.22"
mux = { path = "../mux" }
portable-pty = { path = "../pty", features = ["serde_support"]}
rangeset = { path = "../rangeset" }

View File

@ -81,9 +81,9 @@ fn encode_raw_as_vec(
buffer.extend_from_slice(data);
if is_compressed {
metrics::histogram!("pdu.encode.compressed.size", buffer.len() as f64);
metrics::histogram!("pdu.encode.compressed.size").record(buffer.len() as f64);
} else {
metrics::histogram!("pdu.encode.size", buffer.len() as f64);
metrics::histogram!("pdu.encode.size").record(buffer.len() as f64);
}
Ok(buffer)
@ -211,9 +211,9 @@ async fn decode_raw_async<R: Unpin + AsyncRead + std::fmt::Debug>(
};
if is_compressed {
metrics::histogram!("pdu.decode.compressed.size", data_len as f64);
metrics::histogram!("pdu.decode.compressed.size").record(data_len as f64);
} else {
metrics::histogram!("pdu.decode.size", data_len as f64);
metrics::histogram!("pdu.decode.size").record(data_len as f64);
}
let mut data = vec![0u8; data_len];
@ -259,9 +259,9 @@ fn decode_raw<R: std::io::Read>(mut r: R) -> anyhow::Result<Decoded> {
};
if is_compressed {
metrics::histogram!("pdu.decode.compressed.size", data_len as f64);
metrics::histogram!("pdu.decode.compressed.size").record(data_len as f64);
} else {
metrics::histogram!("pdu.decode.size", data_len as f64);
metrics::histogram!("pdu.decode.size").record(data_len as f64);
}
let mut data = vec![0u8; data_len];
@ -350,8 +350,8 @@ macro_rules! pdu {
let (data, is_compressed) = serialize(s)?;
let encoded_size = encode_raw($vers, serial, &data, is_compressed, w)?;
log::debug!("encode {} size={encoded_size}", stringify!($name));
metrics::histogram!("pdu.size", encoded_size as f64, "pdu" => stringify!($name));
metrics::histogram!("pdu.size.rate", encoded_size as f64, "pdu" => stringify!($name));
metrics::histogram!("pdu.size", "pdu" => stringify!($name)).record(encoded_size as f64);
metrics::histogram!("pdu.size.rate", "pdu" => stringify!($name)).record(encoded_size as f64);
Ok(())
}
,)*
@ -366,8 +366,8 @@ macro_rules! pdu {
let (data, is_compressed) = serialize(s)?;
let encoded_size = encode_raw_async($vers, serial, &data, is_compressed, w).await?;
log::debug!("encode_async {} size={encoded_size}", stringify!($name));
metrics::histogram!("pdu.size", encoded_size as f64, "pdu" => stringify!($name));
metrics::histogram!("pdu.size.rate", encoded_size as f64, "pdu" => stringify!($name));
metrics::histogram!("pdu.size", "pdu" => stringify!($name)).record(encoded_size as f64);
metrics::histogram!("pdu.size.rate", "pdu" => stringify!($name)).record(encoded_size as f64);
Ok(())
}
,)*
@ -390,8 +390,8 @@ macro_rules! pdu {
match decoded.ident {
$(
$vers => {
metrics::histogram!("pdu.size", decoded.data.len() as f64, "pdu" => stringify!($name));
metrics::histogram!("pdu.size.rate", decoded.data.len() as f64, "pdu" => stringify!($name));
metrics::histogram!("pdu.size", "pdu" => stringify!($name)).record(decoded.data.len() as f64);
metrics::histogram!("pdu.size.rate", "pdu" => stringify!($name)).record(decoded.data.len() as f64);
Ok(DecodedPdu {
serial: decoded.serial,
pdu: Pdu::$name(deserialize(decoded.data.as_slice(), decoded.is_compressed)?)
@ -399,8 +399,8 @@ macro_rules! pdu {
}
,)*
_ => {
metrics::histogram!("pdu.size", decoded.data.len() as f64, "pdu" => "??");
metrics::histogram!("pdu.size.rate", decoded.data.len() as f64, "pdu" => "??");
metrics::histogram!("pdu.size", "pdu" => "??").record(decoded.data.len() as f64);
metrics::histogram!("pdu.size.rate", "pdu" => "??").record(decoded.data.len() as f64);
Ok(DecodedPdu {
serial: decoded.serial,
pdu: Pdu::Invalid{ident:decoded.ident}
@ -418,7 +418,7 @@ macro_rules! pdu {
match decoded.ident {
$(
$vers => {
metrics::histogram!("pdu.size", decoded.data.len() as f64, "pdu" => stringify!($name));
metrics::histogram!("pdu.size", "pdu" => stringify!($name)).record(decoded.data.len() as f64);
Ok(DecodedPdu {
serial: decoded.serial,
pdu: Pdu::$name(deserialize(decoded.data.as_slice(), decoded.is_compressed)?)
@ -426,7 +426,7 @@ macro_rules! pdu {
}
,)*
_ => {
metrics::histogram!("pdu.size", decoded.data.len() as f64, "pdu" => "??");
metrics::histogram!("pdu.size", "pdu" => "??").record(decoded.data.len() as f64);
Ok(DecodedPdu {
serial: decoded.serial,
pdu: Pdu::Invalid{ident:decoded.ident}

View File

@ -11,7 +11,7 @@ ahash = "0.8"
config = { path = "../config" }
fnv = "1.0"
intrusive-collections = "0.9"
metrics = "0.21"
metrics = "0.22"
[dev-dependencies]
k9 = "0.12"

View File

@ -242,7 +242,7 @@ impl<K: Hash + Eq + Clone + Debug, V, S: Default + BuildHasher> LfuCache<K, V, S
}
let entry = cursor.into_ref()?;
metrics::histogram!(self.hit, 1.);
metrics::histogram!(self.hit).record(1.);
self.tick += 1;
@ -267,7 +267,7 @@ impl<K: Hash + Eq + Clone + Debug, V, S: Default + BuildHasher> LfuCache<K, V, S
cursor.move_next();
}
metrics::histogram!(self.miss, 1.);
metrics::histogram!(self.miss).record(1.);
None
}

View File

@ -25,7 +25,7 @@ lazy_static = "1.4"
libc = "0.2"
log = "0.4"
luahelper = { path = "../luahelper" }
metrics = "0.21"
metrics = "0.22"
mlua = "0.9"
names = { version = "0.12", default-features = false }
nix = {version="0.25", features=["term"]}

View File

@ -122,10 +122,7 @@ fn send_actions_to_mux(pane: &Weak<dyn Pane>, dead: &Arc<AtomicBool>, actions: V
match pane.upgrade() {
Some(pane) => {
pane.perform_actions(actions);
histogram!(
"send_actions_to_mux.perform_actions.latency",
start.elapsed()
);
histogram!("send_actions_to_mux.perform_actions.latency").record(start.elapsed());
Mux::notify_from_any_thread(MuxNotification::PaneOutput(pane.pane_id()));
}
None => {
@ -135,7 +132,7 @@ fn send_actions_to_mux(pane: &Weak<dyn Pane>, dead: &Arc<AtomicBool>, actions: V
dead.store(true, Ordering::Relaxed);
}
}
histogram!("send_actions_to_mux.rate", 1.);
histogram!("send_actions_to_mux.rate").record(1.);
}
fn parse_buffered_data(pane: Weak<dyn Pane>, dead: &Arc<AtomicBool>, mut rx: FileDescriptor) {
@ -323,7 +320,7 @@ fn read_from_pane_pty(
break;
}
Ok(size) => {
histogram!("read_from_pane_pty.bytes.rate", size as f64);
histogram!("read_from_pane_pty.bytes.rate").record(size as f64);
log::trace!("read_pty pane {pane_id} read {size} bytes");
if let Err(err) = tx.write_all(&buf[..size]) {
error!(

View File

@ -19,7 +19,7 @@ lazy_static = "1.4"
log = "0.4"
libc = "0.2"
lru = "0.12"
metrics = "0.21"
metrics = "0.22"
mux = { path = "../mux" }
openssl = "0.10.57"
parking_lot = "0.12"

View File

@ -79,8 +79,8 @@ macro_rules! rpc {
let start = std::time::Instant::now();
let result = self.send_pdu(Pdu::$request_type(pdu)).await;
let elapsed = start.elapsed();
metrics::histogram!("rpc", elapsed, "method" => stringify!($method_name));
metrics::counter!("rpc.count", 1, "method" => stringify!($method_name));
metrics::histogram!("rpc", "method" => stringify!($method_name)).record(elapsed);
metrics::counter!("rpc.count", "method" => stringify!($method_name)).increment(1);
match result {
Ok(Pdu::$response_type(res)) => Ok(res),
Ok(_) => bail!("unexpected response {:?}", result),
@ -98,8 +98,8 @@ macro_rules! rpc {
let start = std::time::Instant::now();
let result = self.send_pdu(Pdu::$request_type($request_type{})).await;
let elapsed = start.elapsed();
metrics::histogram!("rpc", elapsed, "method" => stringify!($method_name));
metrics::counter!("rpc.count", 1, "method" => stringify!($method_name));
metrics::histogram!("rpc", "method" => stringify!($method_name)).record(elapsed);
metrics::counter!("rpc.count", "method" => stringify!($method_name)).increment(1);
match result {
Ok(Pdu::$response_type(res)) => Ok(res),
Ok(_) => bail!("unexpected response {:?}", result),

View File

@ -28,7 +28,7 @@ lazy_static = "1.4"
lfucache = { path = "../lfucache" }
log = "0.4"
memmap2 = "0.2"
metrics = "0.21"
metrics = "0.22"
ordered-float = "4.1"
rangeset = { path = "../rangeset" }
termwiz = { path = "../termwiz" }

View File

@ -545,7 +545,7 @@ impl ParsedFont {
let face = lib.face_from_locator(&self.handle)?;
*cov = face.compute_coverage();
let elapsed = t.elapsed();
metrics::histogram!("font.compute.codepoint.coverage", elapsed);
metrics::histogram!("font.compute.codepoint.coverage").record(elapsed);
log::debug!(
"{} codepoint coverage computed in {:?}",
self.names.full_name,

View File

@ -593,7 +593,7 @@ impl FontShaper for HarfbuzzShaper {
range,
presentation_width,
);
metrics::histogram!("shape.harfbuzz", start.elapsed());
metrics::histogram!("shape.harfbuzz").record(start.elapsed());
/*
if let Ok(glyphs) = &result {
for g in glyphs {

View File

@ -62,7 +62,7 @@ libc = "0.2"
lfucache = { path = "../lfucache" }
log = "0.4"
luahelper = { path = "../luahelper" }
metrics = "0.21"
metrics = "0.22"
mlua = {version="0.9", features=["send"]}
mux = { path = "../mux" }
mux-lua = { path = "../lua-api-crates/mux" }

View File

@ -634,10 +634,10 @@ impl GlyphCache {
};
if let Some(entry) = self.glyph_cache.get(&key as &dyn GlyphKeyTrait) {
metrics::histogram!("glyph_cache.glyph_cache.hit.rate", 1.);
metrics::histogram!("glyph_cache.glyph_cache.hit.rate").record(1.);
return Ok(Rc::clone(entry));
}
metrics::histogram!("glyph_cache.glyph_cache.miss.rate", 1.);
metrics::histogram!("glyph_cache.glyph_cache.miss.rate").record(1.);
let glyph = match self.load_glyph(info, font, followed_by_space, num_cells) {
Ok(g) => g,

View File

@ -329,7 +329,7 @@ impl HeapQuadAllocator {
other.extend_with(layer_num, &quad.to_vertices());
}
}
metrics::histogram!("quad_buffer_apply", start.elapsed());
metrics::histogram!("quad_buffer_apply").record(start.elapsed());
Ok(())
}
}

View File

@ -2,7 +2,7 @@ use config::configuration;
use config::lua::get_or_create_sub_module;
use config::lua::mlua::Lua;
use hdrhistogram::Histogram;
use metrics::{Counter, Gauge, Key, KeyName, Recorder, SharedString, Unit};
use metrics::{Counter, Gauge, Key, KeyName, Metadata, Recorder, SharedString, Unit};
use parking_lot::Mutex;
use std::collections::HashMap;
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
@ -291,8 +291,7 @@ impl Stats {
let stats = Self::new();
let inner = Arc::clone(&stats.inner);
std::thread::spawn(move || Inner::run(inner));
let rec = Box::new(stats);
metrics::set_boxed_recorder(rec)
metrics::set_global_recorder(stats)
.map_err(|e| anyhow::anyhow!("Failed to set metrics recorder:{}", e))
}
}
@ -304,7 +303,7 @@ impl Recorder for Stats {
fn describe_histogram(&self, _key: KeyName, _unit: Option<Unit>, _description: SharedString) {}
fn register_counter(&self, key: &Key) -> Counter {
fn register_counter(&self, key: &Key, _metadata: &Metadata) -> Counter {
let mut inner = self.inner.lock();
match inner.counters.get(key) {
Some(existing) => Counter::from_arc(existing.clone()),
@ -318,11 +317,11 @@ impl Recorder for Stats {
}
}
fn register_gauge(&self, _key: &Key) -> Gauge {
fn register_gauge(&self, _key: &Key, _metadata: &Metadata) -> Gauge {
Gauge::noop()
}
fn register_histogram(&self, key: &Key) -> metrics::Histogram {
fn register_histogram(&self, key: &Key, _metadata: &Metadata) -> metrics::Histogram {
let mut inner = self.inner.lock();
if key.name().ends_with(".rate") {
match inner.throughput.get(key) {

View File

@ -1423,7 +1423,7 @@ impl TermWindow {
}
fn mux_pane_output_event(&mut self, pane_id: PaneId) {
metrics::histogram!("mux.pane_output_event.rate", 1.);
metrics::histogram!("mux.pane_output_event.rate").record(1.);
if self.is_pane_visible(pane_id) {
if let Some(ref win) = self.window {
win.invalidate();

View File

@ -788,7 +788,7 @@ impl crate::TermWindow {
}
}
};
metrics::histogram!("cached_cluster_shape", shape_resolve_start.elapsed());
metrics::histogram!("cached_cluster_shape").record(shape_resolve_start.elapsed());
log::trace!(
"shape_resolve for cluster len {} -> elapsed {:?}",
cluster.text.len(),

View File

@ -112,8 +112,8 @@ impl crate::TermWindow {
self.last_frame_duration,
self.fps
);
metrics::histogram!("gui.paint.impl", self.last_frame_duration);
metrics::histogram!("gui.paint.impl.rate", 1.);
metrics::histogram!("gui.paint.impl").record(self.last_frame_duration);
metrics::histogram!("gui.paint.impl.rate").record(1.);
// If self.has_animation is some, then the last render detected
// image attachments with multiple frames, so we also need to
@ -181,7 +181,7 @@ impl crate::TermWindow {
.context("layer_for_zindex(0)")?;
let mut layers = layer.quad_allocator();
log::trace!("quad map elapsed {:?}", start.elapsed());
metrics::histogram!("quad.map", start.elapsed());
metrics::histogram!("quad.map").record(start.elapsed());
let mut paint_terminal_background = false;

View File

@ -577,7 +577,7 @@ impl crate::TermWindow {
// TODO: render a thingy to jump to prior prompt
}
*/
metrics::histogram!("paint_pane.lines", start.elapsed());
metrics::histogram!("paint_pane.lines").record(start.elapsed());
log::trace!("lines elapsed {:?}", start.elapsed());
Ok(())

View File

@ -712,7 +712,7 @@ impl crate::TermWindow {
.context("populate_image_quad")?;
}
metrics::histogram!("render_screen_line", start.elapsed());
metrics::histogram!("render_screen_line").record(start.elapsed());
Ok(RenderScreenLineResult {
invalidate_on_hover_change,

View File

@ -34,7 +34,7 @@ lazy_static = "1.4"
libloading = "0.6"
line_drawing = "0.8"
log = "0.4"
metrics = "0.21"
metrics = "0.22"
promise = { path = "../promise" }
raw-window-handle = "0.5"
resize = "0.5"

View File

@ -107,7 +107,7 @@ impl Atlas {
self.texture.write(rect, im);
metrics::histogram!("window.atlas.allocate.success.rate", 1.);
metrics::histogram!("window.atlas.allocate.success.rate").record(1.);
Ok(Sprite {
texture: Rc::clone(&self.texture),
coords: rect,
@ -115,13 +115,13 @@ impl Atlas {
} else {
// It's not possible to satisfy that request
let size = (reserve_width.max(reserve_height) as usize).next_power_of_two();
metrics::histogram!("window.atlas.allocate.failure.rate", 1.);
metrics::histogram!("window.atlas.allocate.failure.rate").record(1.);
Err(OutOfTextureSpace {
size: Some((self.side * 2).max(size)),
current_size: self.side,
})
};
metrics::histogram!("window.atlas.allocate.latency", start.elapsed());
metrics::histogram!("window.atlas.allocate.latency").record(start.elapsed());
res
}

View File

@ -68,10 +68,10 @@ impl SpawnQueue {
// returned function
fn pop_func(&self) -> Option<SpawnFunc> {
if let Some(func) = self.spawned_funcs.lock().unwrap().pop_front() {
metrics::histogram!("executor.spawn_delay", func.at.elapsed());
metrics::histogram!("executor.spawn_delay").record(func.at.elapsed());
Some(func.func)
} else if let Some(func) = self.spawned_funcs_low_pri.lock().unwrap().pop_front() {
metrics::histogram!("executor.spawn_delay.low_pri", func.at.elapsed());
metrics::histogram!("executor.spawn_delay.low_pri").record(func.at.elapsed());
Some(func.func)
} else {
None