1
0
mirror of https://github.com/rclone/rclone.git synced 2026-01-06 10:33:34 +00:00

accounting: add call to clear stats

- Make calls more consistent by changing path to kebab case.
- Add stacktrace information to job panics
This commit is contained in:
Aleksandar Jankovic
2019-07-30 13:22:06 +02:00
committed by Nick Craig-Wood
parent 5be968c0ca
commit 6a3e301303
4 changed files with 56 additions and 4 deletions

View File

@@ -51,6 +51,23 @@ func transferredStats(ctx context.Context, in rc.Params) (rc.Params, error) {
return out, nil
}
func resetStats(ctx context.Context, in rc.Params) (rc.Params, error) {
// Check to see if we should filter by group.
group, err := in.GetString("group")
if rc.NotErrParamNotFound(err) {
return rc.Params{}, err
}
if group != "" {
groups.get(group).ResetCounters()
groups.get(group).ResetErrors()
} else {
groups.clear()
}
return rc.Params{}, nil
}
func init() {
// Init stats container
groups = newStatsGroups()
@@ -143,7 +160,7 @@ Returns the following values:
})
rc.Add(rc.Call{
Path: "core/group_list",
Path: "core/group-list",
Fn: listStats,
Title: "Returns list of stats.",
Help: `
@@ -159,6 +176,19 @@ Returns the following values:
...
]
}
`,
})
rc.Add(rc.Call{
Path: "core/stats-reset",
Fn: resetStats,
Title: "Reset stats.",
Help: `
This clears counters and errors for all stats or specific stats group if group
is provided.
Parameters
- group - name of the stats group (string)
`,
})
}
@@ -287,3 +317,16 @@ func (sg *statsGroups) sum() *StatsInfo {
}
return sum
}
func (sg *statsGroups) clear() {
sg.mu.Lock()
defer sg.mu.Unlock()
for _, stats := range sg.m {
stats.ResetErrors()
stats.ResetCounters()
}
sg.m = make(map[string]*StatsInfo)
sg.order = nil
}