diff options
author | Florian Klink <flokli@flokli.de> | 2024-10-13T15·05+0300 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2024-10-13T16·34+0000 |
commit | 3c3436d3adbe53ef60577b36167c5ae33010a4f7 (patch) | |
tree | 87be558808ada11006d960dd379da46ac2bdd0ba /tvix | |
parent | 15b5bf2003df5fd4a62e47c7ca1f4efbbb5d87cc (diff) |
refactor(tvix/tracing): remove use of lazy_static r/8805
This is now supported in the standard library via std::sync::LazyLock, but requires some manual shuffling around of code. Change-Id: I14bee4068dc73c948321481b5a4e1fc922a89a27 Reviewed-on: https://cl.tvl.fyi/c/depot/+/12611 Tested-by: BuildkiteCI Autosubmit: flokli <flokli@flokli.de> Reviewed-by: tazjin <tazjin@tvl.su>
Diffstat (limited to 'tvix')
-rw-r--r-- | tvix/Cargo.lock | 1 | ||||
-rw-r--r-- | tvix/Cargo.nix | 4 | ||||
-rw-r--r-- | tvix/tracing/Cargo.toml | 1 | ||||
-rw-r--r-- | tvix/tracing/src/lib.rs | 26 |
4 files changed, 15 insertions, 17 deletions
diff --git a/tvix/Cargo.lock b/tvix/Cargo.lock index d713c2350b6f..5301c8d84a02 100644 --- a/tvix/Cargo.lock +++ b/tvix/Cargo.lock @@ -4824,7 +4824,6 @@ dependencies = [ "axum", "http", "indicatif", - "lazy_static", "opentelemetry 0.24.0", "opentelemetry-http", "opentelemetry-otlp", diff --git a/tvix/Cargo.nix b/tvix/Cargo.nix index 8cedc2de7fd6..3dfe08ec7491 100644 --- a/tvix/Cargo.nix +++ b/tvix/Cargo.nix @@ -16179,10 +16179,6 @@ rec { packageId = "indicatif"; } { - name = "lazy_static"; - packageId = "lazy_static"; - } - { name = "opentelemetry"; packageId = "opentelemetry 0.24.0"; optional = true; diff --git a/tvix/tracing/Cargo.toml b/tvix/tracing/Cargo.toml index acd968eb231f..f1621a472f2c 100644 --- a/tvix/tracing/Cargo.toml +++ b/tvix/tracing/Cargo.toml @@ -4,7 +4,6 @@ version = "0.1.0" edition = "2021" [dependencies] -lazy_static = { workspace = true } tracing = { workspace = true, features = ["max_level_trace", "release_max_level_debug"] } tracing-subscriber = { workspace = true, features = ["env-filter"] } indicatif = { workspace = true } diff --git a/tvix/tracing/src/lib.rs b/tvix/tracing/src/lib.rs index fa9723d8cecc..7d5ab56f55ed 100644 --- a/tvix/tracing/src/lib.rs +++ b/tvix/tracing/src/lib.rs @@ -1,5 +1,5 @@ use indicatif::ProgressStyle; -use lazy_static::lazy_static; +use std::sync::LazyLock; use tokio::sync::{mpsc, oneshot}; use tracing::Level; use tracing_indicatif::{filter::IndicatifFilter, writer, IndicatifLayer, IndicatifWriter}; @@ -22,20 +22,24 @@ use tracing_tracy::TracyLayer; pub mod propagate; -lazy_static! { - pub static ref PB_PROGRESS_STYLE: ProgressStyle = ProgressStyle::with_template( - "{span_child_prefix} {wide_msg} {bar:10} ({elapsed}) {pos:>7}/{len:7}" +pub static PB_PROGRESS_STYLE: LazyLock<ProgressStyle> = LazyLock::new(|| { + ProgressStyle::with_template( + "{span_child_prefix} {wide_msg} {bar:10} ({elapsed}) {pos:>7}/{len:7}", ) - .expect("invalid progress template"); - pub static ref PB_TRANSFER_STYLE: ProgressStyle = ProgressStyle::with_template( + .expect("invalid progress template") +}); +pub static PB_TRANSFER_STYLE: LazyLock<ProgressStyle> = LazyLock::new(|| { + ProgressStyle::with_template( "{span_child_prefix} {wide_msg} {binary_bytes:>7}/{binary_total_bytes:7}@{decimal_bytes_per_sec} ({elapsed}) {bar:10} " ) - .expect("invalid progress template"); - pub static ref PB_SPINNER_STYLE: ProgressStyle = ProgressStyle::with_template( - "{span_child_prefix}{spinner} {wide_msg} ({elapsed}) {pos:>7}/{len:7}" + .expect("invalid progress template") +}); +pub static PB_SPINNER_STYLE: LazyLock<ProgressStyle> = LazyLock::new(|| { + ProgressStyle::with_template( + "{span_child_prefix}{spinner} {wide_msg} ({elapsed}) {pos:>7}/{len:7}", ) - .expect("invalid progress template"); -} + .expect("invalid progress template") +}); #[derive(thiserror::Error, Debug)] pub enum Error { |