Richard Crowley %!s(int64=11) %!d(string=hai) anos
pai
achega
d4f1d62226
Modificáronse 3 ficheiros con 22 adicións e 25 borrados
  1. 10 11
      histogram.go
  2. 0 2
      librato/librato.go
  3. 12 12
      timer.go

+ 10 - 11
histogram.go

@@ -4,7 +4,6 @@ package metrics
 type Histogram interface {
 	Clear()
 	Count() int64
-	Sum() int64
 	Max() int64
 	Mean() float64
 	Min() int64
@@ -13,6 +12,7 @@ type Histogram interface {
 	Sample() Sample
 	Snapshot() Histogram
 	StdDev() float64
+	Sum() int64
 	Update(int64)
 	Variance() float64
 }
@@ -59,10 +59,6 @@ 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() }
@@ -97,6 +93,9 @@ func (h *HistogramSnapshot) Snapshot() Histogram { return h }
 // time the snapshot was taken.
 func (h *HistogramSnapshot) StdDev() float64 { return h.sample.StdDev() }
 
+// Sum returns the sum in the sample at the time the snapshot was taken.
+func (h *HistogramSnapshot) Sum() int64 { return h.sample.Sum() }
+
 // Update panics.
 func (*HistogramSnapshot) Update(int64) {
 	panic("Update called on a HistogramSnapshot")
@@ -114,9 +113,6 @@ 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 }
 
@@ -143,6 +139,9 @@ func (NilHistogram) Snapshot() Histogram { return NilHistogram{} }
 // StdDev is a no-op.
 func (NilHistogram) StdDev() float64 { return 0.0 }
 
+// Sum is a no-op.
+func (NilHistogram) Sum() int64 { return 0 }
+
 // Update is a no-op.
 func (NilHistogram) Update(v int64) {}
 
@@ -162,9 +161,6 @@ 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() }
 
@@ -196,6 +192,9 @@ func (h *StandardHistogram) Snapshot() Histogram {
 // StdDev returns the standard deviation of the values in the sample.
 func (h *StandardHistogram) StdDev() float64 { return h.sample.StdDev() }
 
+// Sum returns the sum in the sample.
+func (h *StandardHistogram) Sum() int64 { return h.sample.Sum() }
+
 // Update samples a new value.
 func (h *StandardHistogram) Update(v int64) { h.sample.Update(v) }
 

+ 0 - 2
librato/librato.go

@@ -114,7 +114,6 @@ func (self *Reporter) BuildRequest(now time.Time, r metrics.Registry) (snapshot
 				s := m.Sample()
 				measurement[Name] = fmt.Sprintf("%s.%s", name, "hist")
 				measurement[Count] = uint64(s.Count())
-				measurement[Sum] = s.Sum()
 				measurement[Max] = float64(s.Max())
 				measurement[Min] = float64(s.Min())
 				measurement[SumSquares] = sumSquares(s)
@@ -174,7 +173,6 @@ func (self *Reporter) BuildRequest(now time.Time, r metrics.Registry) (snapshot
 				gauges[0] = Measurement{
 					Name:       libratoName,
 					Count:      uint64(m.Count()),
-					Sum:        m.Mean() * float64(m.Count()),
 					Max:        float64(m.Max()),
 					Min:        float64(m.Min()),
 					SumSquares: sumSquaresTimer(m),

+ 12 - 12
timer.go

@@ -8,7 +8,6 @@ import (
 // Timers capture the duration and rate of events.
 type Timer interface {
 	Count() int64
-	Sum() int64
 	Max() int64
 	Mean() float64
 	Min() int64
@@ -20,6 +19,7 @@ type Timer interface {
 	RateMean() float64
 	Snapshot() Timer
 	StdDev() float64
+	Sum() int64
 	Time(func())
 	Update(time.Duration)
 	UpdateSince(time.Time)
@@ -77,9 +77,6 @@ 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 }
 
@@ -115,6 +112,9 @@ func (NilTimer) Snapshot() Timer { return NilTimer{} }
 // StdDev is a no-op.
 func (NilTimer) StdDev() float64 { return 0.0 }
 
+// Sum is a no-op.
+func (NilTimer) Sum() int64 { return 0 }
+
 // Time is a no-op.
 func (NilTimer) Time(func()) {}
 
@@ -140,11 +140,6 @@ 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()
@@ -206,6 +201,11 @@ func (t *StandardTimer) StdDev() float64 {
 	return t.histogram.StdDev()
 }
 
+// Sum returns the sum in the sample.
+func (t *StandardTimer) Sum() int64 {
+	return t.histogram.Sum()
+}
+
 // Record the duration of the execution of the given function.
 func (t *StandardTimer) Time(f func()) {
 	ts := time.Now()
@@ -244,9 +244,6 @@ 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() }
 
@@ -291,6 +288,9 @@ func (t *TimerSnapshot) Snapshot() Timer { return t }
 // was taken.
 func (t *TimerSnapshot) StdDev() float64 { return t.histogram.StdDev() }
 
+// Sum returns the sum at the time the snapshot was taken.
+func (t *TimerSnapshot) Sum() int64 { return t.histogram.Sum() }
+
 // Time panics.
 func (*TimerSnapshot) Time(func()) {
 	panic("Time called on a TimerSnapshot")