Skip to content

Commit 133c290

Browse files
devanbenzphiljb
andauthored
feat: file store merge metrics (#26615) (#26834)
Co-authored-by: Phil Bracikowski <13472206+philjb@users.noreply.github.com> closes #26614
1 parent e8ef25b commit 133c290

File tree

5 files changed

+302
-30
lines changed

5 files changed

+302
-30
lines changed

pkg/metrics/timer.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,29 @@ import (
55
"time"
66
)
77

8-
// The timer type is used to store a duration.
8+
// Timer type is used to store a duration.
99
type Timer struct {
10-
val int64
10+
val atomic.Int64
1111
desc *desc
1212
}
1313

1414
// Name returns the name of the timer.
1515
func (t *Timer) Name() string { return t.desc.Name }
1616

1717
// Value atomically returns the value of the timer.
18-
func (t *Timer) Value() time.Duration { return time.Duration(atomic.LoadInt64(&t.val)) }
18+
func (t *Timer) Value() time.Duration { return time.Duration(t.val.Load()) }
1919

2020
// Update sets the timer value to d.
21-
func (t *Timer) Update(d time.Duration) { atomic.StoreInt64(&t.val, int64(d)) }
21+
func (t *Timer) Update(d time.Duration) { t.val.Store(int64(d)) }
2222

2323
// UpdateSince sets the timer value to the difference between since and the current time.
2424
func (t *Timer) UpdateSince(since time.Time) { t.Update(time.Since(since)) }
2525

26+
// AddSince adds to the timer's current value the difference between since and the current time.
27+
func (t *Timer) AddSince(since time.Time) { t.val.Add(int64(time.Since(since))) }
28+
2629
// String returns a string representation using the name and value of the timer.
27-
func (t *Timer) String() string { return t.desc.Name + ": " + time.Duration(t.val).String() }
30+
func (t *Timer) String() string { return t.desc.Name + ": " + time.Duration(t.val.Load()).String() }
2831

2932
// Time updates the timer to the duration it takes to call f.
3033
func (t *Timer) Time(f func()) {

tsdb/engine/tsm1/file_store.gen.go

Lines changed: 114 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)