From e0356f5aae4b61e29ac2cc7f545811bfb8c9542f Mon Sep 17 00:00:00 2001 From: Chaitanya Date: Tue, 29 Oct 2019 15:43:21 +0530 Subject: [PATCH] rcd: Adding group parameter to stats --- fs/accounting/accounting.go | 1 + fs/accounting/stats.go | 1 + fs/accounting/stats_groups.go | 1 + fs/accounting/transfer.go | 3 +++ 4 files changed, 6 insertions(+) diff --git a/fs/accounting/accounting.go b/fs/accounting/accounting.go index 11018c199..1c838a55b 100644 --- a/fs/accounting/accounting.go +++ b/fs/accounting/accounting.go @@ -378,6 +378,7 @@ func (acc *Account) RemoteStats() (out rc.Params) { percentageDone = int(100 * float64(a) / float64(b)) } out["percentage"] = percentageDone + out["group"] = acc.stats.group return out } diff --git a/fs/accounting/stats.go b/fs/accounting/stats.go index afa06cf46..dac69aa67 100644 --- a/fs/accounting/stats.go +++ b/fs/accounting/stats.go @@ -40,6 +40,7 @@ type StatsInfo struct { startedTransfers []*Transfer // currently active transfers oldTimeRanges timeRanges // a merged list of time ranges for the transfers oldDuration time.Duration // duration of transfers we have culled + group string } // NewStats creates an initialised StatsInfo diff --git a/fs/accounting/stats_groups.go b/fs/accounting/stats_groups.go index 5cbdb682e..69175d160 100644 --- a/fs/accounting/stats_groups.go +++ b/fs/accounting/stats_groups.go @@ -245,6 +245,7 @@ func GlobalStats() *StatsInfo { // NewStatsGroup creates new stats under named group. func NewStatsGroup(group string) *StatsInfo { stats := NewStats() + stats.group = group groups.set(group, stats) return stats } diff --git a/fs/accounting/transfer.go b/fs/accounting/transfer.go index 9fc7f8f04..75c771e49 100644 --- a/fs/accounting/transfer.go +++ b/fs/accounting/transfer.go @@ -18,6 +18,7 @@ type TransferSnapshot struct { StartedAt time.Time `json:"started_at"` CompletedAt time.Time `json:"completed_at,omitempty"` Error error `json:"-"` + Group string `json:"group"` } // MarshalJSON implements json.Marshaler interface. @@ -26,6 +27,7 @@ func (as TransferSnapshot) MarshalJSON() ([]byte, error) { if as.Error != nil { err = as.Error.Error() } + type Alias TransferSnapshot return json.Marshal(&struct { Error string `json:"error"` @@ -176,5 +178,6 @@ func (tr *Transfer) Snapshot() TransferSnapshot { StartedAt: tr.startedAt, CompletedAt: tr.completedAt, Error: tr.err, + Group: tr.stats.group, } }