Skip to content

Commit

Permalink
Reset metrics on config change (#437)
Browse files Browse the repository at this point in the history
* Reset metrics on config change

* reset metrics logic as a method of Storage

* Fix line length linting issues
  • Loading branch information
Kashkovsky authored Mar 26, 2022
1 parent b444097 commit dd94570
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ func (r *Runner) Run(ctx context.Context, logger *zap.Logger) {

lastKnownConfig = rawConfig

metrics.Default.ResetAll()

if cancel != nil {
cancel()
}
Expand Down
6 changes: 6 additions & 0 deletions src/utils/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ func (ms *Storage) Read(name string) uint64 {
return sum
}

func (ms *Storage) ResetAll() {
for k := range ms.trackers {
ms.trackers[k] = &metricTracker{}
}
}

// NewWriter creates a writer for accumulated writes to the storage
func (ms *Storage) NewWriter(name, jobID string) *Writer {
return &Writer{ms: ms, jobID: jobID, name: name, value: 0}
Expand Down

0 comments on commit dd94570

Please sign in to comment.