1
0
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:
Matt Gibson
2026-01-15 05:36:58 -08:00
parent 624910a463
commit 0f668f15ed
3 changed files with 22 additions and 3 deletions

5
akd/Cargo.lock generated
View File

@@ -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]]

View File

@@ -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"]

View File

@@ -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")
}