|
@@ -28,10 +28,11 @@ type Reporter struct {
|
|
|
Registry metrics.Registry
|
|
Registry metrics.Registry
|
|
|
Percentiles []float64 // percentiles to report on histogram metrics
|
|
Percentiles []float64 // percentiles to report on histogram metrics
|
|
|
TimerAttributes map[string]interface{} // units in which timers will be displayed
|
|
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 {
|
|
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) {
|
|
func Librato(r metrics.Registry, d time.Duration, e string, t string, s string, p []float64, u time.Duration) {
|
|
@@ -78,10 +79,10 @@ func sumSquaresTimer(t metrics.Timer) float64 {
|
|
|
|
|
|
|
|
func (self *Reporter) BuildRequest(now time.Time, r metrics.Registry) (snapshot Batch, err error) {
|
|
func (self *Reporter) BuildRequest(now time.Time, r metrics.Registry) (snapshot Batch, err error) {
|
|
|
snapshot = Batch{
|
|
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,
|
|
Source: self.Source,
|
|
|
}
|
|
}
|
|
|
- snapshot.MeasureTime = now.Unix()
|
|
|
|
|
snapshot.Gauges = make([]Measurement, 0)
|
|
snapshot.Gauges = make([]Measurement, 0)
|
|
|
snapshot.Counters = make([]Measurement, 0)
|
|
snapshot.Counters = make([]Measurement, 0)
|
|
|
histogramGaugeCount := 1 + len(self.Percentiles)
|
|
histogramGaugeCount := 1 + len(self.Percentiles)
|