Skip to content

Commit

Permalink
Bridge: Replace lazy_static macro with once_cell (#1055)
Browse files Browse the repository at this point in the history
See also #1024 

lazy_static is unmaintained, once_cell is the new hotness. This PR swaps
out the one lazy_static invocation for the equivalent lazy construct
from once_cell.
  • Loading branch information
svix-nick authored Aug 24, 2023
1 parent 287c57b commit 15cfc31
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion bridge/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bridge/svix-bridge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ enum_dispatch = "0.3"
envsubst = "0.2.1"
http = "0.2"
hyper = { version = "0.14", features = ["full"] }
lazy_static = "1.4"
once_cell = "1.18.0"
opentelemetry = { version = "0.18.0", features = ["rt-tokio"] }
opentelemetry-http = "0.7.0"
opentelemetry-otlp = { version = "0.11.0", features = ["metrics", "grpc-tonic", "http-proto", "reqwest-client"] }
Expand Down
12 changes: 5 additions & 7 deletions bridge/svix-bridge/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use self::config::Config;
use clap::Parser;
use lazy_static::lazy_static;
use once_cell::sync::Lazy;
use opentelemetry::runtime::Tokio;
use opentelemetry::sdk::export::metrics::aggregation::delta_temporality_selector;
use opentelemetry::sdk::metrics::controllers::BasicController;
Expand Down Expand Up @@ -32,12 +32,10 @@ static GLOBAL: Jemalloc = Jemalloc;
#[cfg(all(target_env = "msvc", feature = "jemalloc"))]
compile_error!("jemalloc cannot be enabled on msvc");

lazy_static! {
// Seems like it would be useful to be able to configure this.
// In some docker setups, hostname is sometimes the container id, and advertising this can be
// helpful.
pub static ref INSTANCE_ID: String = KsuidMs::new(None, None).to_string();
}
// Seems like it would be useful to be able to configure this.
// In some docker setups, hostname is sometimes the container id, and advertising this can be
// helpful.
static INSTANCE_ID: Lazy<String> = Lazy::new(|| KsuidMs::new(None, None).to_string());

fn get_svc_identifiers(cfg: &Config) -> opentelemetry::sdk::Resource {
opentelemetry::sdk::Resource::new(vec![
Expand Down

0 comments on commit 15cfc31

Please sign in to comment.