-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix non-cumulative stats report on config update
- Loading branch information
Showing
3 changed files
with
42 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package metrics | ||
|
||
func NewStatsTracker(metrics *Metrics) *StatsTracker { | ||
return &StatsTracker{metrics: metrics} | ||
} | ||
|
||
// StatsTracker generalizes tracking stats changes between reports | ||
type StatsTracker struct { | ||
lastStats PerTargetStats | ||
lastTotals Stats | ||
metrics *Metrics | ||
} | ||
|
||
func (st *StatsTracker) sumStats(groupTargets bool) (stats PerTargetStats, totals Stats, statsInterval PerTargetStats, totalsInterval Stats) { | ||
stats, totals = st.metrics.SumAllStats(groupTargets) | ||
statsInterval, totalsInterval = stats.Diff(st.lastStats), Diff(totals, st.lastTotals) | ||
st.lastStats, st.lastTotals = stats, totals | ||
|
||
return | ||
} |