Skip to content

Commit

Permalink
Add msg.lost to the emitted metrics.
Browse files Browse the repository at this point in the history
This is similar to v0.9.X `alltime.lost` series metric

We were tracking it internally and intecting it into the log-stream,
just not tracking it in the metrics registry
  • Loading branch information
Edward Muller committed Apr 29, 2015
1 parent 2b7876e commit 81f2871
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
### 0.10.3 2015-04-29 Edward Muller ([email protected])

* Add `msg.lost` to the emitted metrics. This is similar to v0.9.X
`alltime.lost`

### 0.10.2 2015-04-29 Edward Muller ([email protected])

* Fix -version flag.
Expand Down
9 changes: 6 additions & 3 deletions http_outlet.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ type HTTPOutlet struct {
errLogger *log.Logger

// Various stats that we'll collect, see NewHTTPOutlet for names
inboxLengthGauge metrics.Gauge // The number of outstanding batches, updated every time we try a post
postSuccessTimer metrics.Timer // The timing data for successful posts
postFailureTimer metrics.Timer // The timing data for failed posts
inboxLengthGauge metrics.Gauge // The number of outstanding batches, updated every time we try a post
postSuccessTimer metrics.Timer // The timing data for successful posts
postFailureTimer metrics.Timer // The timing data for failed posts
msgLostCount metrics.Counter // The count of lost messages
}

// NewHTTPOutlet returns a properly constructed HTTPOutlet for the given shuttle
Expand All @@ -74,6 +75,7 @@ func NewHTTPOutlet(s *Shuttle) *HTTPOutlet {
inboxLengthGauge: metrics.GetOrRegisterGauge("outlet.inbox.length", s.MetricsRegistry),
postSuccessTimer: metrics.GetOrRegisterTimer("outlet.post.success", s.MetricsRegistry),
postFailureTimer: metrics.GetOrRegisterTimer("outlet.post.failure", s.MetricsRegistry),
msgLostCount: metrics.GetOrRegisterCounter("msg.lost", s.MetricsRegistry),
}
}

Expand Down Expand Up @@ -128,6 +130,7 @@ func (h *HTTPOutlet) retryPost(batch Batch) {
}
h.errLogger.Printf(RetryWithTypeFormat, false, msgCount, inboxLength, uuid, attempts, err, err)
h.lost.Add(msgCount)
h.msgLostCount.Inc(int64(msgCount))
}
return
}
Expand Down
7 changes: 7 additions & 0 deletions http_outlet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"regexp"
"testing"
"time"

"github.com/heroku/log-shuttle/Godeps/_workspace/src/github.com/rcrowley/go-metrics"
)

type testEOFHelper struct {
Expand Down Expand Up @@ -90,6 +92,11 @@ func TestOutletEOFRetryMax(t *testing.T) {
t.Errorf("lost != 1, == %q\n", lost)
}

mrLost := metrics.GetOrRegisterCounter("msg.lost", s.MetricsRegistry)
if lost := mrLost.Count(); lost != 1 {
t.Errorf("lost != 1, == %q\n", lost)
}

logMessageCheck := regexp.MustCompile(`EOF`)
logMessage := logCapture.Bytes()
if !logMessageCheck.Match(logMessage) {
Expand Down

0 comments on commit 81f2871

Please sign in to comment.