From 212673aeaa02215cb0eb1554170861b0b99d93dc Mon Sep 17 00:00:00 2001 From: Stephen Cirner Date: Thu, 6 Jan 2022 12:40:33 -0500 Subject: [PATCH] Move from github link to crates.io reference for minstant now that it exists. (#21) --- Cargo.lock | 18 ++++-------------- Cargo.toml | 2 +- src/middleware/logging_grpc.rs | 5 ++--- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c1897b0..c5357db 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -991,25 +991,15 @@ dependencies = [ [[package]] name = "minstant" -version = "0.0.2" -source = "git+https://github.com/tikv/minstant.git#dcd3e1e66aef844ce0bb5433d46f7a779fbff2e8" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cb320648b7883b43ce5dfbc5c6f4a84038194c3f67b4fcb7d05c994e6006557" dependencies = [ "ctor", "libc", - "minstant_macro", "wasi 0.7.0", ] -[[package]] -name = "minstant_macro" -version = "0.1.0" -source = "git+https://github.com/tikv/minstant.git#dcd3e1e66aef844ce0bb5433d46f7a779fbff2e8" -dependencies = [ - "proc-macro-error", - "quote", - "syn", -] - [[package]] name = "mio" version = "0.7.14" @@ -1136,7 +1126,7 @@ dependencies = [ "minitrace", "minitrace-datadog", "minitrace-macro", - "minstant 0.0.2", + "minstant 0.1.1", "prost", "prost-types", "quick-error", diff --git a/Cargo.toml b/Cargo.toml index 6609fc1..3f8bbe4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,7 @@ reqwest = { version = "0.11" } minitrace = { git = "https://github.com/tikv/minitrace-rust.git" } minitrace-macro = { git = "https://github.com/tikv/minitrace-rust.git" } minitrace-datadog = { git = "https://github.com/tikv/minitrace-rust.git" } -minstant = { git = "https://github.com/tikv/minstant.git" } +minstant = "0.1.1" # TODO can we upgrade this? tokio = { version = "1.0", features = ["macros", "rt-multi-thread", "sync"] } tokio-stream = "0.1" diff --git a/src/middleware/logging_grpc.rs b/src/middleware/logging_grpc.rs index 89424aa..bb44f98 100644 --- a/src/middleware/logging_grpc.rs +++ b/src/middleware/logging_grpc.rs @@ -69,10 +69,9 @@ where .unwrap_or(&default_trace_id) .to_str() .unwrap(); - let start = minstant::now(); + let start = minstant::Instant::now(); let response = inner.call(req).await?; - let end = minstant::now(); - let elapsed_seconds = (end - start) as f64 * minstant::nanos_per_cycle() / 1_000_000_000f64; + let elapsed_seconds = start.elapsed().as_secs_f64(); if elapsed_seconds > upper_logging_bounds { log::warn!("Trace ID: {} took {} second(s)", trace_id, elapsed_seconds);