Skip to content

Commit

Permalink
add measure time back in, problem was on librato side
Browse files Browse the repository at this point in the history
  • Loading branch information
nicpottier committed Aug 28, 2017
1 parent 41db893 commit d81e996
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 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}
c.buffer <- gauge{Name: strings.ToLower(name), Value: value, MeasureTime: time.Now().Unix()}
}

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

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

// read up to our count of gauges
Expand Down Expand Up @@ -116,7 +117,7 @@ func (c *Sender) flush(count int) {
return
}

logrus.WithField("comp", "librato").WithField("count", len(reqPayload.Gauges)).Debug("flushed to librato")
logrus.WithField("comp", "librato").WithField("count", len(reqPayload.Gauges)).Info("flushed to librato")
}

// Stop stops our sender, callers can use the WaitGroup used during initialization to block for stop
Expand All @@ -128,13 +129,15 @@ func (c *Sender) Stop() {
}

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

type payload struct {
Source string `json:"source"`
Gauges []gauge `json:"gauges"`
MeasureTime int64 `json:"measure_time"`
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 d81e996

Please sign in to comment.