Skip to content

Commit

Permalink
fix lock timer
Browse files Browse the repository at this point in the history
  • Loading branch information
mazrean committed Mar 6, 2023
1 parent b97c321 commit 200df67
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions locker/locker.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (v *Value[T]) Read(f func(v *T)) {
if isutools.Enable {
timer := prometheus.NewTimer(lockHistVec.WithLabelValues(v.name, "read"))
v.locker.RLock()
timer.ObserveDuration()
defer timer.ObserveDuration()
} else {
v.locker.RLock()
}
Expand All @@ -50,7 +50,7 @@ func (v *Value[T]) Write(f func(v *T)) {
if isutools.Enable {
timer := prometheus.NewTimer(lockHistVec.WithLabelValues(v.name, "write"))
v.locker.Lock()
timer.ObserveDuration()
defer timer.ObserveDuration()
} else {
v.locker.Lock()
}
Expand Down

0 comments on commit 200df67

Please sign in to comment.