stats: fix missing StatsInfo fields in the computation of the group sum

This commit is contained in:
Carlo Mion 2021-11-04 09:24:12 +01:00 committed by Nick Craig-Wood
parent c2600f9e4d
commit 7b7d780fff
2 changed files with 22 additions and 12 deletions

View File

@ -24,6 +24,8 @@ const (
var MaxCompletedTransfers = 100
// StatsInfo accounts all transfers
// N.B.: if this struct is modified, please remember to also update sum() function in stats_groups
// to correctly count the updated fields
type StatsInfo struct {
mu sync.RWMutex
ctx context.Context

View File

@ -359,23 +359,31 @@ func (sg *statsGroups) sum(ctx context.Context) *StatsInfo {
{
sum.bytes += stats.bytes
sum.errors += stats.errors
sum.fatalError = sum.fatalError || stats.fatalError
sum.retryError = sum.retryError || stats.retryError
sum.checks += stats.checks
sum.transfers += stats.transfers
sum.deletes += stats.deletes
sum.deletedDirs += stats.deletedDirs
sum.renames += stats.renames
sum.checking.merge(stats.checking)
sum.transferring.merge(stats.transferring)
sum.inProgress.merge(stats.inProgress)
if sum.lastError == nil && stats.lastError != nil {
sum.lastError = stats.lastError
}
sum.startedTransfers = append(sum.startedTransfers, stats.startedTransfers...)
sum.fatalError = sum.fatalError || stats.fatalError
sum.retryError = sum.retryError || stats.retryError
if stats.retryAfter.After(sum.retryAfter) {
// Update the retryAfter field only if it is a later date than the current one in the sum
sum.retryAfter = stats.retryAfter
}
sum.checks += stats.checks
sum.checking.merge(stats.checking)
sum.checkQueue += stats.checkQueue
sum.checkQueueSize += stats.checkQueueSize
sum.transfers += stats.transfers
sum.transferring.merge(stats.transferring)
sum.transferQueueSize += stats.transferQueueSize
sum.oldDuration += stats.oldDuration
sum.renames += stats.renames
sum.renameQueue += stats.renameQueue
sum.renameQueueSize += stats.renameQueueSize
sum.deletes += stats.deletes
sum.deletedDirs += stats.deletedDirs
sum.inProgress.merge(stats.inProgress)
sum.startedTransfers = append(sum.startedTransfers, stats.startedTransfers...)
sum.oldTimeRanges = append(sum.oldTimeRanges, stats.oldTimeRanges...)
sum.oldDuration += stats.oldDuration
stats.average.mu.Lock()
sum.average.speed += stats.average.speed
stats.average.mu.Unlock()