diff --git a/changelog.md b/changelog.md index dbadd03..260b1c0 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,8 @@ +### 0.10.3 2015-04-29 Edward Muller (edward@heroku.com) + +* Add `msg.lost` to the emitted metrics. This is similar to v0.9.X + `alltime.lost` + ### 0.10.2 2015-04-29 Edward Muller (edward@heroku.com) * Fix -version flag. diff --git a/http_outlet.go b/http_outlet.go index 426cb69..70078e7 100644 --- a/http_outlet.go +++ b/http_outlet.go @@ -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 @@ -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), } } @@ -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 } diff --git a/http_outlet_test.go b/http_outlet_test.go index 1dd572b..1dc32e0 100644 --- a/http_outlet_test.go +++ b/http_outlet_test.go @@ -9,6 +9,8 @@ import ( "regexp" "testing" "time" + + "github.com/heroku/log-shuttle/Godeps/_workspace/src/github.com/rcrowley/go-metrics" ) type testEOFHelper struct { @@ -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) {