Skip to content

Commit 10d381e

Browse files
authored
refactor(resource): add tracing to parent selector methods (#1482)
Signed-off-by: Gaius <gaius.qi@gmail.com>
1 parent edf6dfc commit 10d381e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

dragonfly-client/src/resource/parent_selector.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ impl ParentSelector {
148148
/// This function performs weighted random selection where parents with higher weights
149149
/// (better idle bandwidth) have a higher probability of being selected. If weight
150150
/// calculation fails, falls back to uniform random selection.
151+
#[instrument(skip_all)]
151152
pub fn select(&self, parents: Vec<CollectedParent>) -> CollectedParent {
152153
let weights: Vec<u64> = parents
153154
.iter()
@@ -195,6 +196,7 @@ impl ParentSelector {
195196
/// - Creates a new gRPC connection if one doesn't exist.
196197
/// - Spawns a background task to continuously sync host metrics (bandwidth, load).
197198
/// - Updates the connection's request counter.
199+
#[instrument(skip_all)]
198200
pub async fn register(&self, parents: &[Peer]) -> Result<()> {
199201
let dfdaemon_shutdown = self.shutdown.clone();
200202
let mut join_set = JoinSet::new();
@@ -265,6 +267,7 @@ impl ParentSelector {
265267
/// - Triggers connection shutdown.
266268
/// - Removes the weight entry.
267269
/// - Removes the connection from the pool.
270+
#[instrument(skip_all)]
268271
pub fn unregister(&self, parents: &[Peer]) {
269272
for parent in parents {
270273
info!("unregister parent {}", parent.id);
@@ -352,6 +355,7 @@ impl ParentSelector {
352355
}
353356

354357
/// Calculates the idle transmission bandwidth of a host.
358+
#[instrument(skip_all)]
355359
fn get_idle_tx_bandwidth(host: &Host) -> u64 {
356360
let network = match &host.network {
357361
Some(network) => network,
@@ -443,6 +447,7 @@ impl PersistentCacheParentSelector {
443447
/// This function performs weighted random selection where parents with higher weights
444448
/// (better idle bandwidth) have a higher probability of being selected. If weight
445449
/// calculation fails, falls back to uniform random selection.
450+
#[instrument(skip_all)]
446451
pub fn select(&self, parents: Vec<CollectedParent>) -> CollectedParent {
447452
let weights: Vec<u64> = parents
448453
.iter()
@@ -490,6 +495,7 @@ impl PersistentCacheParentSelector {
490495
/// - Creates a new gRPC connection if one doesn't exist.
491496
/// - Spawns a background task to continuously sync host metrics (bandwidth, load).
492497
/// - Updates the connection's request counter.
498+
#[instrument(skip_all)]
493499
pub async fn register(&self, parents: &[PersistentCachePeer]) -> Result<()> {
494500
let dfdaemon_shutdown = self.shutdown.clone();
495501
let mut join_set = JoinSet::new();
@@ -563,6 +569,7 @@ impl PersistentCacheParentSelector {
563569
/// - Triggers connection shutdown.
564570
/// - Removes the weight entry.
565571
/// - Removes the connection from the pool.
572+
#[instrument(skip_all)]
566573
pub fn unregister(&self, parents: &[PersistentCachePeer]) {
567574
for parent in parents {
568575
info!("unregister persistent cache parent {}", parent.id);
@@ -656,6 +663,7 @@ impl PersistentCacheParentSelector {
656663
}
657664

658665
/// Calculates the idle transmission bandwidth of a host.
666+
#[instrument(skip_all)]
659667
fn get_idle_tx_bandwidth(host: &Host) -> u64 {
660668
let network = match &host.network {
661669
Some(network) => network,

0 commit comments

Comments
 (0)