From 71ece5fe6ba3556e340ab390f1f4a8859b2deb27 Mon Sep 17 00:00:00 2001 From: Todd Gruben Date: Fri, 10 Oct 2014 15:46:52 +0000 Subject: [PATCH] added a setbit counter --- index/fragment_container.go | 1 + util/statd.go | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/index/fragment_container.go b/index/fragment_container.go index 5c1e0ae22..4bdc315b4 100644 --- a/index/fragment_container.go +++ b/index/fragment_container.go @@ -267,6 +267,7 @@ func (self *FragmentContainer) SetBit(frag_id util.SUUID, bitmap_id uint64, pos fragment.requestChan <- request result := request.Response() util.SendTimer("fragmant_container_SetBit", result.exec_time.Nanoseconds()) + util.SendInc("fragmant_container_SetBit") return result.answer.(bool), nil } return false, errors.New("Invalid Bitmap Handle") diff --git a/util/statd.go b/util/statd.go index ef90d3e87..3455db813 100644 --- a/util/statd.go +++ b/util/statd.go @@ -14,12 +14,14 @@ type args struct { } var ( - count chan args + timer chan args + count chan string end chan bool ) func init() { - count = make(chan args, 100) + timer = make(chan args, 100) + count = make(chan string, 100) end = make(chan bool) stat_config := config.GetStringDefault("statsd_server", "127.0.0.1:8125") log.Println("New Stats", stat_config) @@ -27,8 +29,10 @@ func init() { go func() { for { select { - case ci := <-count: + case ci := <-timer: stats.Gauge(ci.stat, ci.delta, ci.rate) + case stat := <-count: + stats.Inc(stat, 1, 1.0) case <-end: log.Println("DONE Stats") return @@ -40,7 +44,11 @@ func init() { func SendTimer(stat string, delta int64) { pstat := "pilosa." + stat - count <- args{pstat, delta, 1.0} + timer <- args{pstat, delta, 1.0} +} +func SendInc(stat string) { + pstat := "pilosa." + stat + count <- pstat } func ShutdownStats() {