Skip to content

feat: add trace info about source seed client in the client SDK - #4906

Open
Samyra312007 wants to merge 1 commit into
dragonflyoss:mainfrom
Samyra312007:feat/seed-client-trace-info
Open

feat: add trace info about source seed client in the client SDK#4906
Samyra312007 wants to merge 1 commit into
dragonflyoss:mainfrom
Samyra312007:feat/seed-client-trace-info

Conversation

@Samyra312007

Copy link
Copy Markdown

Description

Add OpenTelemetry span attributes and structured log fields to trace which seed peer is selected and used during peer downloads. This gives operators end-to-end visibility into seed client selection, enabling diagnosis of load balancing issues.

Changes

  • internal/dflog/logger.go: Added WithSeedPeer(hostID, hostname, ip, port) structured logging helper
  • pkg/types/types.go: Added OTel attribute key constants for seed peer identity (d7y.scheduler.seed_peer.*)
  • pkg/rpc/dfdaemon/client/client_v2.go: Added setPeerTargetAttributes() which sets d7y.dfdaemon.target span attribute on all download RPCs (DownloadTask, SyncPieces, DownloadPersistentTask, DownloadPersistentCacheTask)
  • scheduler/resource/standard/seed_peer.go: Added OTel span attributes and WithSeedPeer logging in TriggerDownloadTask, TriggerTask, and Select
  • scheduler/service/service_v2.go: Added priority span attribute in downloadTaskBySeedPeer; replaced context.Background() with context.WithoutCancel(ctx) to preserve trace context in fire-and-forget goroutines
  • scheduler/service/service_v1.go: Same pattern — priority span attribute and context.WithoutCancel(ctx) in triggerTask and triggerSeedPeerTask

Related Issue

Closes #4841

Motivation and Context

Without this change, there is no way to identify which seed peer a peer is downloading from. This makes it impossible to detect load imbalances across seed peers (e.g., all peers hitting the same seed peer while others are idle). The new trace info flows through OpenTelemetry spans and structured logs, giving operators full visibility into seed peer selection and utilization.

Screenshots (if appropriate)

N/A

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation Update (if none of the other choices apply)

Checklist

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

@codecov

codecov Bot commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 15.09434% with 45 lines in your changes missing coverage. Please review.
✅ Project coverage is 28.40%. Comparing base (5523218) to head (c72a103).

Files with missing lines Patch % Lines
scheduler/resource/standard/seed_peer.go 0.00% 27 Missing ⚠️
pkg/rpc/dfdaemon/client/client_v2.go 0.00% 11 Missing ⚠️
internal/dflog/logger.go 0.00% 3 Missing ⚠️
scheduler/service/service_v1.go 33.33% 1 Missing and 1 partial ⚠️
scheduler/service/service_v2.go 77.77% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4906      +/-   ##
==========================================
- Coverage   28.45%   28.40%   -0.05%     
==========================================
  Files         235      235              
  Lines       23228    23271      +43     
==========================================
+ Hits         6609     6610       +1     
- Misses      16169    16209      +40     
- Partials      450      452       +2     
Flag Coverage Δ
unittests 28.40% <15.09%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
pkg/types/types.go 0.00% <ø> (ø)
scheduler/service/service_v1.go 85.62% <33.33%> (-0.23%) ⬇️
scheduler/service/service_v2.go 39.75% <77.77%> (-0.01%) ⬇️
internal/dflog/logger.go 0.00% <0.00%> (ø)
pkg/rpc/dfdaemon/client/client_v2.go 0.00% <0.00%> (ø)
scheduler/resource/standard/seed_peer.go 15.70% <0.00%> (-2.26%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@BraveY

BraveY commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Hi Samyra312007, we should add the trace info in the client sdk instead of scheduler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add trace info about source seed client in the client sdk

5 participants