From 62ebb4e3e2ef903e76f22ce4c24e2df1496a0d6a Mon Sep 17 00:00:00 2001 From: Peter Nose Date: Tue, 7 Nov 2023 11:43:32 +0100 Subject: [PATCH] go/worker/compute/executor: Defer call to time.Since --- go/worker/compute/executor/committee/node.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/go/worker/compute/executor/committee/node.go b/go/worker/compute/executor/committee/node.go index 2956ffaf469..12fccf9530a 100644 --- a/go/worker/compute/executor/committee/node.go +++ b/go/worker/compute/executor/committee/node.go @@ -831,7 +831,9 @@ func (n *Node) proposeBatch( // Commit I/O and state write logs to storage. storageErr := func() error { start := time.Now() - defer storageCommitLatency.With(n.getMetricLabels()).Observe(time.Since(start).Seconds()) + defer func() { + storageCommitLatency.With(n.getMetricLabels()).Observe(time.Since(start).Seconds()) + }() ctx, cancel := context.WithCancel(roundCtx) defer cancel()