func (s *Statsd) WriteLoop(c <-chan time.Time, w io.Writer) {
	for range c {
		if _, err := s.WriteTo(w); err != nil {
			s.logger.Log("during", "WriteTo", "err", err)
		}
	}
}
WriteLoop is a helper method that invokes WriteTo to the passed writer every
time the passed channel fires. This method blocks until the channel is
closed, so clients probably want to run it in its own goroutine. For typical
usage, create a time.Ticker and pass its C channel to this method.
package statsd
import (
	"fmt"
	"io"
	"time"
	"github.com/go-kit/kit/log"
	"github.com/go-kit/kit/metrics"
	"github.com/go-kit/kit/metrics/internal/lv"
	"github.com/go-kit/kit/metrics/internal/ratemap"
	"github.com/go-kit/kit/util/conn"
)
type Statsd struct {
	prefix string
	rates  *ratemap.RateMap
	counters *lv.Space
	gauges   *lv.Space
	timings  *lv.Space
	logger log.Logger
}
func New(prefix string, logger log.Logger) *Statsd {
	return &Statsd{
		prefix:   prefix,
		rates:    ratemap.New(),
		counters: lv.NewSpace(),
		gauges:   lv.NewSpace(),
		timings:  lv.NewSpace(),
		logger:   logger,
	}
}
func (s *Statsd) NewCounter(name string, sampleRate float64) *Counter {
	s.rates.Set(s.prefix+name, sampleRate)
	return &Counter{
		name: s.prefix + name,
		obs:  s.counters.Observe,
	}
}
func (s *Statsd) NewGauge(name string) *Gauge {
	return &Gauge{
		name: s.prefix + name,
		obs:  s.gauges.Observe,
		add:  s.gauges.Add,
	}
}
func (s *Statsd) NewTiming(name string, sampleRate float64) *Timing {
	s.rates.Set(s.prefix+name, sampleRate)
	return &Timing{
		name: s.prefix + name,
		obs:  s.timings.Observe,
	}
}