Skip to content

Commit

Permalink
don't send measure time in librato calls so aggregation is more correct
Browse files Browse the repository at this point in the history
  • Loading branch information
nicpottier committed Aug 28, 2017
1 parent 4f94dc6 commit 41db893
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion backends/rapidpro/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func writeMsgToDB(b *backend, m *DBMsg) error {
// queue this up to be handled by RapidPro
b.notifier.addHandleMsgNotification(m.ID_)

return err
return err
}

const selectMsgSQL = `
Expand Down
17 changes: 7 additions & 10 deletions librato/librato.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (c *Sender) AddGauge(name string, value float64) {
return
}

c.buffer <- gauge{Name: strings.ToLower(name), Value: value, MeasureTime: time.Now().Unix()}
c.buffer <- gauge{Name: strings.ToLower(name), Value: value}
}

// Start starts our librato sender, callers can use Stop to stop it
Expand Down Expand Up @@ -81,9 +81,8 @@ func (c *Sender) flush(count int) {

// build our payload
reqPayload := &payload{
MeasureTime: time.Now().Unix(),
Source: c.source,
Gauges: make([]gauge, 0, len(c.buffer)),
Source: c.source,
Gauges: make([]gauge, 0, len(c.buffer)),
}

// read up to our count of gauges
Expand Down Expand Up @@ -129,15 +128,13 @@ func (c *Sender) Stop() {
}

type gauge struct {
Name string `json:"name"`
Value float64 `json:"value"`
MeasureTime int64 `json:"measure_time"`
Name string `json:"name"`
Value float64 `json:"value"`
}

type payload struct {
MeasureTime int64 `json:"measure_time"`
Source string `json:"source"`
Gauges []gauge `json:"gauges"`
Source string `json:"source"`
Gauges []gauge `json:"gauges"`
}

// Sender is responsible for collecting gauges and sending them in batches to our librato server
Expand Down

0 comments on commit 41db893

Please sign in to comment.