code: func RequestStats() macaron.Handler {
  	stats := requestStats{
  		responseCounts:    make(map[string]map[int]*stats.Counter32),
  		latencyHistograms: make(map[string]*stats.LatencyHistogram15s32),
  		sizeMeters:        make(map[string]*stats.Meter32),
  	}
  
  	return func(ctx *macaron.Context) {
  		start := time.Now()
  		rw := ctx.Resp.(macaron.ResponseWriter)
  		// call next handler. This will return after all handlers
  		// have completed and the request has been sent.
  		ctx.Next()
  		status := rw.Status()
  		path := pathSlug(ctx.Req.URL.Path)
  		// graphite cluster requests use local=1
  		// this way we can differentiate "full" render requests from client to MT (encompassing data processing, proxing to graphite, etc)
  		// from "subrequests" where metrictank is called by graphite and graphite does the processing and returns to the client
  		if ctx.Req.Request.Form.Get("local") == "1" {
  			path += "-local"
  		}
  		stats.PathStatusCount(path, status)
  		stats.PathLatency(path, time.Since(start))
  		// only record the request size if the request succeeded.
  		if status < 300 {
  			stats.PathSize(path, rw.Size())
  		}
  	}
  }
docs: // RequestStats returns a middleware that tracks request metrics.