Skip to content

Commit

Permalink
metrics: remove inactiveMeter, timer Stop()
Browse files Browse the repository at this point in the history
  • Loading branch information
zeim839 committed May 14, 2024
1 parent 8a99570 commit 25d2746
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 15 deletions.
3 changes: 1 addition & 2 deletions metrics/internal/sampledata.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func ExampleMetrics() metrics.Registry {
//metrics.NewRegisteredHistogram("test/histogram", registry, metrics.NewSampleSnapshot(3, []int64{1, 2, 3}))
metrics.NewRegisteredHistogram("test/histogram", registry, s)
}
registry.Register("test/meter", metrics.NewInactiveMeter())
registry.Register("test/meter", metrics.NewMeter())
{
timer := metrics.NewRegisteredResettingTimer("test/resetting_timer", registry)
timer.Update(10 * time.Millisecond)
Expand All @@ -68,7 +68,6 @@ func ExampleMetrics() metrics.Registry {
timer.Update(120 * time.Millisecond)
timer.Update(23 * time.Millisecond)
timer.Update(24 * time.Millisecond)
timer.Stop()
}
registry.Register("test/empty_resetting_timer", metrics.NewResettingTimer().Snapshot())

Expand Down
13 changes: 0 additions & 13 deletions metrics/timer.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,13 @@ type TimerSnapshot interface {
// Timer capture the duration and rate of events.
type Timer interface {
Snapshot() TimerSnapshot
Stop()
Time(func())
UpdateSince(time.Time)
Update(time.Duration)
}

// GetOrRegisterTimer returns an existing Timer or constructs and registers a
// new StandardTimer.
// Be sure to unregister the meter from the registry once it is of no use to
// allow for garbage collection.
func GetOrRegisterTimer(name string, r Registry) Timer {
if nil == r {
r = DefaultRegistry
Expand All @@ -31,7 +28,6 @@ func GetOrRegisterTimer(name string, r Registry) Timer {
}

// NewCustomTimer constructs a new StandardTimer from a Histogram and a Meter.
// Be sure to call Stop() once the timer is of no use to allow for garbage collection.
func NewCustomTimer(h Histogram, m Meter) Timer {
if !Enabled {
return NilTimer{}
Expand All @@ -43,8 +39,6 @@ func NewCustomTimer(h Histogram, m Meter) Timer {
}

// NewRegisteredTimer constructs and registers a new StandardTimer.
// Be sure to unregister the meter from the registry once it is of no use to
// allow for garbage collection.
func NewRegisteredTimer(name string, r Registry) Timer {
c := NewTimer()
if nil == r {
Expand All @@ -56,7 +50,6 @@ func NewRegisteredTimer(name string, r Registry) Timer {

// NewTimer constructs a new StandardTimer using an exponentially-decaying
// sample with the same reservoir size and alpha as UNIX load averages.
// Be sure to call Stop() once the timer is of no use to allow for garbage collection.
func NewTimer() Timer {
if !Enabled {
return NilTimer{}
Expand All @@ -71,7 +64,6 @@ func NewTimer() Timer {
type NilTimer struct{}

func (NilTimer) Snapshot() TimerSnapshot { return (*emptySnapshot)(nil) }
func (NilTimer) Stop() {}
func (NilTimer) Time(f func()) { f() }
func (NilTimer) Update(time.Duration) {}
func (NilTimer) UpdateSince(time.Time) {}
Expand All @@ -94,11 +86,6 @@ func (t *StandardTimer) Snapshot() TimerSnapshot {
}
}

// Stop stops the meter.
func (t *StandardTimer) Stop() {
t.meter.Stop()
}

// Time record the duration of the execution of the given function.
func (t *StandardTimer) Time(f func()) {
ts := time.Now()
Expand Down

0 comments on commit 25d2746

Please sign in to comment.