func (s *Server) statsKeeper(name string, statsChan <-chan string) {
	reqMetric := metrics.NewMap("url", metrics.NewInt(0))
	em := metrics.NewEventMetrics(time.Now()).
		AddMetric("req", reqMetric).
		AddLabel("module", name)
	doExport := time.Tick(s.statsInterval)
	for {
		select {
		case url := <-statsChan:
			reqMetric.IncKey(url)
		case ts := <-doExport:
			em.Timestamp = ts
			s.dataChan <- em.Clone()
			s.l.Info(em.String())
		}
	}
}
// statsKeeper manages the stats and exports those stats at a regular basis.
// Currently we only maintain the number of requests received per URL.
statsKeeper manages the stats and exports those stats at a regular basis.
Currently we only maintain the number of requests received per URL.
// statsKeeper manages the stats and exports those stats at a regular basis . // Currently we only maintain the number of requests received per URL .
func (s *Server) statsKeeper(name string, statsChan <-chan string) {
	reqMetric := metrics.NewMap("url", metrics.NewInt(0))
	em := metrics.NewEventMetrics(time.Now()).
		AddMetric("req", reqMetric).
		AddLabel("module", name)
	doExport := time.Tick(s.statsInterval)
	for {
		select {
		case url := <-statsChan:
			reqMetric.IncKey(url)
		case ts := <-doExport:
			em.Timestamp = ts
			s.dataChan <- em.Clone()
			s.l.Info(em.String())
		}
	}
}
func ( s * Server ) statsKeeper ( name string , statsChan <- chan string ) { reqMetric := metrics . NewMap ( " " , metrics . NewInt ( 0 ) ) em := metrics . NewEventMetrics ( time . Now ( ) ) . AddMetric ( " " , reqMetric ) . AddLabel ( " " , name ) doExport := time . Tick ( s . statsInterval ) for { select { case url := <- statsChan : reqMetric . IncKey ( url ) case ts := <- doExport : em . Timestamp = ts s . dataChan <- em . Clone ( ) s . l . Info ( em . String ( ) ) } } }
statsKeeper manages the stats and exports those stats at a regular basis.
statsKeeper manages the stats and exports those stats at a regular basis .