func NewStatsWriter(cfg *config.AgentConfig, in <-chan pb.StatsPayload) *StatsWriter {
	sw := &StatsWriter{
		in:        in,
		stats:     &info.StatsWriterInfo{},
		stop:      make(chan struct{}),
		flushChan: make(chan chan struct{}),
		syncMode:  cfg.SynchronousFlushing,
		easylog:   logutil.NewThrottled(5, 10*time.Second), // no more than 5 messages every 10 seconds
	}
	climit := cfg.StatsWriter.ConnectionLimit
	if climit == 0 {
		// Allow 1% of the connection limit to outgoing sends. The original
		// connection limit was removed and used to be 2000 (1% = 20)
		climit = 20
	}
	qsize := cfg.StatsWriter.QueueSize
	if qsize == 0 {
		payloadSize := float64(maxEntriesPerPayload * bytesPerEntry)
		// default to 25% of maximum memory.
		maxmem := cfg.MaxMemory / 4
		if maxmem == 0 {
			// or 250MB if unbound
			maxmem = 250 * 1024 * 1024
		}
		qsize = int(math.Max(1, maxmem/payloadSize))
	}
	log.Debugf("Stats writer initialized (climit=%d qsize=%d)", climit, qsize)
	sw.senders = newSenders(cfg, sw, pathStats, climit, qsize)
	return sw
}
// NewStatsWriter returns a new StatsWriter. It must be started using Run.
NewStatsWriter returns a new StatsWriter. It must be started using Run.
// NewStatsWriter returns a new StatsWriter . It must be started using Run .
func NewStatsWriter(cfg *config.AgentConfig, in <-chan pb.StatsPayload) *StatsWriter {
	sw := &StatsWriter{
		in:        in,
		stats:     &info.StatsWriterInfo{},
		stop:      make(chan struct{}),
		flushChan: make(chan chan struct{}),
		syncMode:  cfg.SynchronousFlushing,
		easylog:   logutil.NewThrottled(5, 10*time.Second), 
	}
	climit := cfg.StatsWriter.ConnectionLimit
	if climit == 0 {
		climit = 20
	}
	qsize := cfg.StatsWriter.QueueSize
	if qsize == 0 {
		payloadSize := float64(maxEntriesPerPayload * bytesPerEntry)
		maxmem := cfg.MaxMemory / 4
		if maxmem == 0 {
			maxmem = 250 * 1024 * 1024
		}
		qsize = int(math.Max(1, maxmem/payloadSize))
	}
	log.Debugf("Stats writer initialized (climit=%d qsize=%d)", climit, qsize)
	sw.senders = newSenders(cfg, sw, pathStats, climit, qsize)
	return sw
}
func NewStatsWriter ( cfg * config . AgentConfig , in <- chan pb . StatsPayload ) * StatsWriter { sw := & StatsWriter { in : in , stats : & info . StatsWriterInfo { } , stop : make ( chan struct { } ) , flushChan : make ( chan chan struct { } ) , syncMode : cfg . SynchronousFlushing , easylog : logutil . NewThrottled ( 5 , 10 * time . Second ) , } climit := cfg . StatsWriter . ConnectionLimit if climit == 0 { climit = 20 } qsize := cfg . StatsWriter . QueueSize if qsize == 0 { payloadSize := float64 ( maxEntriesPerPayload * bytesPerEntry ) maxmem := cfg . MaxMemory / 4 if maxmem == 0 { maxmem = 250 * 1024 * 1024 } qsize = int ( math . Max ( 1 , maxmem / payloadSize ) ) } log . Debugf ( " " , climit , qsize ) sw . senders = newSenders ( cfg , sw , pathStats , climit , qsize ) return sw }
NewStatsWriter returns a new StatsWriter.
NewStatsWriter returns a new StatsWriter .
// no more than 5 messages every 10 seconds // Allow 1% of the connection limit to outgoing sends. The original // connection limit was removed and used to be 2000 (1% = 20) // default to 25% of maximum memory. // or 250MB if unbound