Skip to content

Commit d27ba2e

Browse files
authored
libsql: Improve sync protocol probe tracing (#1994)
2 parents 48238be + 92dce9a commit d27ba2e

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

libsql/src/database/builder.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ cfg_replication! {
363363
use super::SyncProtocol;
364364
match sync_protocol {
365365
p @ (SyncProtocol::Auto | SyncProtocol::V2) => {
366+
tracing::trace!("Probing for sync protocol version for {}", url);
366367
let client = hyper::client::Client::builder()
367368
.build::<_, hyper::Body>(connector.clone());
368369

@@ -381,6 +382,8 @@ cfg_replication! {
381382
.await
382383
.map_err(|err| crate::Error::Sync(err.into()))?;
383384

385+
tracing::trace!("Probe for sync protocol version for {} returned status {}", url, res.status());
386+
384387
if res.status() == http::StatusCode::UNAUTHORIZED {
385388
return Err(crate::Error::Sync("Unauthorized".into()));
386389
}
@@ -397,15 +400,18 @@ cfg_replication! {
397400
}
398401

399402
if res.status().is_success() {
403+
tracing::trace!("Using sync protocol v2 for {}", url);
400404
return Builder::new_synced_database(path, url, auth_token)
401405
.remote_writes(true)
402406
.read_your_writes(read_your_writes)
403407
.build()
404408
.await;
405409
}
406-
410+
tracing::trace!("Using sync protocol v1 for {} based on probe results", url);
411+
}
412+
SyncProtocol::V1 => {
413+
tracing::trace!("Using sync protocol v1 for {}", url);
407414
}
408-
SyncProtocol::V1 => {}
409415
}
410416
}
411417

0 commit comments

Comments
 (0)