Remove thread ID from metrics
All checks were successful
All checks were successful
This commit is contained in:
parent
efa357a92b
commit
7bc70d83c0
18
src/lib.rs
18
src/lib.rs
|
@ -598,8 +598,7 @@ struct MetricsGuard {
|
|||
impl MetricsGuard {
|
||||
fn guard(name: &'static str, id: u64) -> Self {
|
||||
tracing::trace!("Starting {name}-{id}");
|
||||
metrics::counter!(format!("async-cpupool.{name}.launched"), "id" => id.to_string())
|
||||
.increment(1);
|
||||
metrics::counter!(format!("async-cpupool.{name}.launched")).increment(1);
|
||||
|
||||
MetricsGuard {
|
||||
name,
|
||||
|
@ -616,8 +615,8 @@ impl MetricsGuard {
|
|||
|
||||
impl Drop for MetricsGuard {
|
||||
fn drop(&mut self) {
|
||||
metrics::counter!(format!("async-cpupool.{}.closed", self.name), "clean" => (!self.armed).to_string(), "id" => self.id.to_string()).increment(1);
|
||||
metrics::histogram!(format!("async-cpupool.{}.duration", self.name), "clean" => (!self.armed).to_string(), "id" => self.id.to_string()).record(self.start.elapsed().as_secs_f64());
|
||||
metrics::counter!(format!("async-cpupool.{}.closed", self.name), "clean" => (!self.armed).to_string()).increment(1);
|
||||
metrics::histogram!(format!("async-cpupool.{}.duration", self.name), "clean" => (!self.armed).to_string()).record(self.start.elapsed().as_secs_f64());
|
||||
tracing::trace!("Stopping {}-{}", self.name, self.id);
|
||||
}
|
||||
}
|
||||
|
@ -634,7 +633,7 @@ fn run(
|
|||
loop {
|
||||
match selector::blocking_select(signal.recv_async(), receiver.recv_async()) {
|
||||
selector::Either::Left(_) | selector::Either::Right(Err(_)) => break,
|
||||
selector::Either::Right(Ok(send_fn)) => invoke_send_fn(name, id, send_fn),
|
||||
selector::Either::Right(Ok(send_fn)) => invoke_send_fn(name, send_fn),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -643,17 +642,16 @@ fn run(
|
|||
drop(closed_tx);
|
||||
}
|
||||
|
||||
fn invoke_send_fn(name: &'static str, id: u64, send_fn: SendFn) {
|
||||
fn invoke_send_fn(name: &'static str, send_fn: SendFn) {
|
||||
let start = Instant::now();
|
||||
metrics::counter!(format!("async-cpupool.{name}.operation.start"), "id" => id.to_string())
|
||||
.increment(1);
|
||||
metrics::counter!(format!("async-cpupool.{name}.operation.start")).increment(1);
|
||||
|
||||
let res = std::panic::catch_unwind(std::panic::AssertUnwindSafe(move || {
|
||||
(send_fn)();
|
||||
}));
|
||||
|
||||
metrics::counter!(format!("async-cpupool.{name}.operation.end"), "complete" => res.is_ok().to_string(), "id" => id.to_string()).increment(1);
|
||||
metrics::histogram!(format!("async-cpupool.{name}.operation.duration"), "complete" => res.is_ok().to_string(), "id" => id.to_string()).record(start.elapsed().as_secs_f64());
|
||||
metrics::counter!(format!("async-cpupool.{name}.operation.end"), "complete" => res.is_ok().to_string()).increment(1);
|
||||
metrics::histogram!(format!("async-cpupool.{name}.operation.duration"), "complete" => res.is_ok().to_string()).record(start.elapsed().as_secs_f64());
|
||||
|
||||
if let Err(e) = res {
|
||||
tracing::trace!("panic in spawned task: {e:?}");
|
||||
|
|
Loading…
Reference in a new issue