Skip to content

Commit

Permalink
Diagnostic data: include SDK version and git hash (#1101)
Browse files Browse the repository at this point in the history
  • Loading branch information
ok300 authored Oct 13, 2024
1 parent 3c28f5f commit 677d22d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions libs/sdk-core/src/breez_services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,7 @@ impl BreezServices {
req: ConnectRequest,
event_listener: Box<dyn EventListener>,
) -> BreezServicesResult<Arc<BreezServices>> {
let sdk_version = option_env!("CARGO_PKG_VERSION").unwrap_or_default();
let sdk_git_hash = option_env!("SDK_GIT_HASH").unwrap_or_default();
let (sdk_version, sdk_git_hash) = Self::get_sdk_version();
info!("SDK v{sdk_version} ({sdk_git_hash})");
let start = Instant::now();
let services = BreezServicesBuilder::new(req.config)
Expand All @@ -199,6 +198,12 @@ impl BreezServices {
Ok(services)
}

fn get_sdk_version() -> (&'static str, &'static str) {
let sdk_version = option_env!("CARGO_PKG_VERSION").unwrap_or_default();
let sdk_git_hash = option_env!("SDK_GIT_HASH").unwrap_or_default();
(sdk_version, sdk_git_hash)
}

/// Internal utility method that starts the BreezServices background tasks for this instance.
///
/// It should be called once right after creating [BreezServices], since it is essential for the
Expand Down Expand Up @@ -2168,6 +2173,8 @@ impl BreezServices {
}

async fn generate_sdk_diagnostic_data(&self) -> SdkResult<Value> {
let (sdk_version, sdk_git_hash) = Self::get_sdk_version();
let version = format!("SDK v{sdk_version} ({sdk_git_hash})");
let state = crate::serializer::value::to_value(&self.persister.get_node_state()?)?;
let payments = crate::serializer::value::to_value(
&self
Expand All @@ -2184,6 +2191,7 @@ impl BreezServices {
let lsp_id = crate::serializer::value::to_value(&self.persister.get_lsp_id()?)?;

let res = json!({
"version": version,
"node_state": state,
"payments": payments,
"channels": channels,
Expand Down

0 comments on commit 677d22d

Please sign in to comment.