Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/libratofloor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rcrowley committed Nov 8, 2014
2 parents 890aecc + a924b1e commit 6f41298
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions librato/librato.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ type Reporter struct {
Registry metrics.Registry
Percentiles []float64 // percentiles to report on histogram metrics
TimerAttributes map[string]interface{} // units in which timers will be displayed
intervalSec int64
}

func NewReporter(r metrics.Registry, d time.Duration, e string, t string, s string, p []float64, u time.Duration) *Reporter {
return &Reporter{e, t, s, d, r, p, translateTimerAttributes(u)}
return &Reporter{e, t, s, d, r, p, translateTimerAttributes(u), int64(d / time.Second)}
}

func Librato(r metrics.Registry, d time.Duration, e string, t string, s string, p []float64, u time.Duration) {
Expand Down Expand Up @@ -78,10 +79,10 @@ func sumSquaresTimer(t metrics.Timer) float64 {

func (self *Reporter) BuildRequest(now time.Time, r metrics.Registry) (snapshot Batch, err error) {
snapshot = Batch{
MeasureTime: now.Unix(),
// coerce timestamps to a stepping fn so that they line up in Librato graphs
MeasureTime: (now.Unix() / self.intervalSec) * self.intervalSec,
Source: self.Source,
}
snapshot.MeasureTime = now.Unix()
snapshot.Gauges = make([]Measurement, 0)
snapshot.Counters = make([]Measurement, 0)
histogramGaugeCount := 1 + len(self.Percentiles)
Expand Down

0 comments on commit 6f41298

Please sign in to comment.