mirror of
https://github.com/bitwarden/server
synced 2026-02-09 21:20:01 +00:00
Add tracing to AKD config init
This commit is contained in:
5
akd/Cargo.lock
generated
5
akd/Cargo.lock
generated
@@ -519,6 +519,7 @@ dependencies = [
|
||||
"blake3",
|
||||
"config",
|
||||
"serde",
|
||||
"tracing",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
@@ -2249,11 +2250,15 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"akd",
|
||||
"akd_storage",
|
||||
"anyhow",
|
||||
"bitwarden-akd-configuration",
|
||||
"common",
|
||||
"config",
|
||||
"serde",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
"uuid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -11,6 +11,7 @@ akd.workspace = true
|
||||
blake3.workspace = true
|
||||
config = { workspace = true, optional = true }
|
||||
serde = { workspace = true, optional = true }
|
||||
tracing = { workspace = true, optional = true }
|
||||
uuid = { version = "1.18.1", features = ["serde"] }
|
||||
|
||||
[lints]
|
||||
@@ -18,4 +19,5 @@ workspace = true
|
||||
|
||||
[features]
|
||||
config = ["dep:config", "dep:serde"]
|
||||
default = ["config"]
|
||||
tracing = ["dep:tracing"]
|
||||
default = ["tracing"]
|
||||
|
||||
@@ -50,19 +50,31 @@ impl BitwardenV1Configuration {
|
||||
///
|
||||
/// # Panics
|
||||
/// Panics if called more than once.
|
||||
#[cfg_attr(
|
||||
feature = "tracing",
|
||||
tracing::instrument(level = "info", name = "BitwardenV1Configuration::init")
|
||||
)]
|
||||
pub fn init(installation_context: Uuid) {
|
||||
let installation_context = [BITWARDEN_V1, installation_context.as_bytes()].concat();
|
||||
INSTALLATION_CONTEXT
|
||||
.set(installation_context)
|
||||
.expect("BitwardenV1Configuration already initialized");
|
||||
#[cfg(feature = "tracing")]
|
||||
tracing::info!("BitwardenV1Configuration initialization successful");
|
||||
}
|
||||
|
||||
/// Get the installation context. Panics if not initialized.
|
||||
/// # Panics
|
||||
/// Panics if `BitwardenV1Configuration::init()` has not been called.
|
||||
fn get_context() -> &'static [u8] {
|
||||
INSTALLATION_CONTEXT
|
||||
.get()
|
||||
let maybe_installation_context = INSTALLATION_CONTEXT.get();
|
||||
|
||||
#[cfg(feature = "tracing")]
|
||||
if maybe_installation_context.is_none() {
|
||||
tracing::error!("BitwardenV1Configuration::init() must be called before use");
|
||||
}
|
||||
|
||||
maybe_installation_context
|
||||
.expect("BitwardenV1Configuration::init() must be called before use")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user