Skip to content

Commit

Permalink
diagnostics: cherry pick speedtest disable (#10509)
Browse files Browse the repository at this point in the history
Cherry pick PR #10449 into the release branch
  • Loading branch information
dvovk authored May 27, 2024
1 parent 23a0c2c commit 5f28aaf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
4 changes: 3 additions & 1 deletion diagnostics/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
type DiagnosticClient struct {
metricsMux *http.ServeMux
dataDirPath string
speedTest bool

syncStats SyncStatistics
snapshotFileList SnapshoFilesList
Expand All @@ -26,10 +27,11 @@ type DiagnosticClient struct {
networkSpeedMutex sync.Mutex
}

func NewDiagnosticClient(metricsMux *http.ServeMux, dataDirPath string) *DiagnosticClient {
func NewDiagnosticClient(metricsMux *http.ServeMux, dataDirPath string, speedTest bool) *DiagnosticClient {
return &DiagnosticClient{
metricsMux: metricsMux,
dataDirPath: dataDirPath,
speedTest: speedTest,
syncStats: SyncStatistics{},
hardwareInfo: HardwareInfo{},
snapshotFileList: SnapshoFilesList{},
Expand Down
19 changes: 4 additions & 15 deletions diagnostics/speedtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,11 @@ import (
)

func (d *DiagnosticClient) setupSpeedtestDiagnostics(rootCtx context.Context) {
ticker := time.NewTicker(30 * time.Minute)
go func() {
d.networkSpeedMutex.Lock()
d.networkSpeed = d.runSpeedTest(rootCtx)
d.networkSpeedMutex.Unlock()

for {
select {
case <-ticker.C:
d.networkSpeedMutex.Lock()
d.networkSpeed = d.runSpeedTest(rootCtx)
d.networkSpeedMutex.Unlock()
case <-rootCtx.Done():
ticker.Stop()
return
}
if d.speedTest {
d.networkSpeedMutex.Lock()
d.networkSpeed = d.runSpeedTest(rootCtx)
d.networkSpeedMutex.Unlock()
}
}()
}
Expand Down

0 comments on commit 5f28aaf

Please sign in to comment.