Skip to content

Commit

Permalink
fix acuumulator.Clone in encrypted jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
arriven committed Apr 22, 2022
1 parent 651ae79 commit dcc1b46
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/utils/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,13 @@ func (r *Reporter) WriteSummary(logger *zap.Logger) {
}

// NewAccumulator returns a new metrics Accumulator for the Reporter.
func (r *Reporter) NewAccumulator(jobID string) *Accumulator { return newAccumulator(jobID, r) }
func (r *Reporter) NewAccumulator(jobID string) *Accumulator {
if r == nil {
return nil
}

return newAccumulator(jobID, r)
}

// Accumulator for statistical metrics for use in a single job. Requires Flush()-ing to Reporter.
// Not concurrency-safe.
Expand Down Expand Up @@ -228,13 +234,15 @@ func (a *Accumulator) Flush() {
}

// Clone a new, blank metrics Accumulator with the same Reporter as the original.
func (a *Accumulator) Clone(jobID string) *Accumulator { return newAccumulator(jobID, a.r) }

func newAccumulator(jobID string, r *Reporter) *Accumulator {
if r == nil {
func (a *Accumulator) Clone(jobID string) *Accumulator {
if a == nil {
return nil
}

return newAccumulator(jobID, a.r)
}

func newAccumulator(jobID string, r *Reporter) *Accumulator {
res := &Accumulator{
jobID: jobID,
r: r,
Expand Down

0 comments on commit dcc1b46

Please sign in to comment.