sonots il y a 11 ans
Parent
commit
9ea68306eb
2 fichiers modifiés avec 23 ajouts et 0 suppressions
  1. 11 0
      histogram.go
  2. 12 0
      timer.go

+ 11 - 0
histogram.go

@@ -4,6 +4,7 @@ package metrics
 type Histogram interface {
 	Clear()
 	Count() int64
+	Sum() int64
 	Max() int64
 	Mean() float64
 	Min() int64
@@ -58,6 +59,10 @@ func (*HistogramSnapshot) Clear() {
 // taken.
 func (h *HistogramSnapshot) Count() int64 { return h.sample.Count() }
 
+// Sum returns the sum in the sample at the time the snapshot was
+// taken.
+func (h *HistogramSnapshot) Sum() int64 { return h.sample.Sum() }
+
 // Max returns the maximum value in the sample at the time the snapshot was
 // taken.
 func (h *HistogramSnapshot) Max() int64 { return h.sample.Max() }
@@ -109,6 +114,9 @@ func (NilHistogram) Clear() {}
 // Count is a no-op.
 func (NilHistogram) Count() int64 { return 0 }
 
+// Sum is a no-op.
+func (NilHistogram) Sum() int64 { return 0 }
+
 // Max is a no-op.
 func (NilHistogram) Max() int64 { return 0 }
 
@@ -154,6 +162,9 @@ func (h *StandardHistogram) Clear() { h.sample.Clear() }
 // cleared.
 func (h *StandardHistogram) Count() int64 { return h.sample.Count() }
 
+// Sum returns the sum in the sample.
+func (h *StandardHistogram) Sum() int64 { return h.sample.Sum() }
+
 // Max returns the maximum value in the sample.
 func (h *StandardHistogram) Max() int64 { return h.sample.Max() }
 

+ 12 - 0
timer.go

@@ -8,6 +8,7 @@ import (
 // Timers capture the duration and rate of events.
 type Timer interface {
 	Count() int64
+	Sum() int64
 	Max() int64
 	Mean() float64
 	Min() int64
@@ -76,6 +77,9 @@ type NilTimer struct {
 // Count is a no-op.
 func (NilTimer) Count() int64 { return 0 }
 
+// Sum is a no-op.
+func (NilTimer) Sum() int64 { return 0 }
+
 // Max is a no-op.
 func (NilTimer) Max() int64 { return 0 }
 
@@ -136,6 +140,11 @@ func (t *StandardTimer) Count() int64 {
 	return t.histogram.Count()
 }
 
+// Sum returns the sum in the sample.
+func (t *StandardTimer) Sum() int64 {
+	return t.histogram.Sum()
+}
+
 // Max returns the maximum value in the sample.
 func (t *StandardTimer) Max() int64 {
 	return t.histogram.Max()
@@ -235,6 +244,9 @@ type TimerSnapshot struct {
 // taken.
 func (t *TimerSnapshot) Count() int64 { return t.histogram.Count() }
 
+// Sum returns the sum at the time the snapshot was taken.
+func (t *TimerSnapshot) Sum() int64 { return t.histogram.Sum() }
+
 // Max returns the maximum value at the time the snapshot was taken.
 func (t *TimerSnapshot) Max() int64 { return t.histogram.Max() }