Skip to content

Commit

Permalink
Duplicate values in debug timer (#1033)
Browse files Browse the repository at this point in the history
* duplicate-values-in-debug-timer

* format duration only in ms

* use int ms
  • Loading branch information
kstoykov authored and hexoscott committed Aug 28, 2024
1 parent 18da74c commit 2dfde4f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion zk/utils/debug_timer.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,17 @@ func (t *Timer) LogTimer() {
}

t.elapsed = time.Since(t.start)
keysAndValues := make([]interface{}, 0, 2+2*len(t.taskNames))

logMessage := fmt.Sprintf("duration: %s, task: %s", t.elapsed, t.taskNames[0])
keysAndValues = append(keysAndValues, "duration-ms", fmt.Sprintf("%d", t.elapsed/time.Millisecond), "task", t.taskNames[0])

for i, task := range t.taskNames[1:] {
logMessage += fmt.Sprintf(", subtask%d: %s", i+1, task)
keysAndValues = append(keysAndValues, fmt.Sprintf("subtask%d", i+1), task)
}

log.Info("[cdk-metric] " + logMessage)
log.Info("[cdk-metric] "+logMessage, keysAndValues...)
}

func (t *Timer) Elapsed() time.Duration {
Expand Down

0 comments on commit 2dfde4f

Please sign in to comment.