func (ps *rateLimiter) Permits(n int64) bool {
	if n <= 0 {
		return true // no sensible value in n, disable rate limiting
	}

	keep := true

	ps.mu.Lock()

	if ps.realRateLocked() > ps.stats.TargetRate {
		// we're keeping more than the target rate, drop
		keep = false
		ps.stats.RecentTracesDropped += float64(n)
	}

	// this should be done *after* testing the real rate against the target rate,
	// otherwise we could end up systematically dropping the first payload.
	ps.stats.RecentPayloadsSeen++
	ps.stats.RecentTracesSeen += float64(n)

	ps.mu.Unlock()

	if !keep {
		log.Debugf("Rate limiting at rate %.2f dropped payload with %d traces", ps.TargetRate(), n)
	}
	return keep
}
// Permits reports wether the rate limiter should allow n more traces to
// enter the pipeline. Permits calls alter internal statistics which affect
// the result of calling RealRate(). It should only be called once per payload.
Permits reports wether the rate limiter should allow n more traces to
enter the pipeline. Permits calls alter internal statistics which affect
the result of calling RealRate(). It should only be called once per payload.
// Permits reports wether the rate limiter should allow n more traces to // enter the pipeline . Permits calls alter internal statistics which affect // the result of calling RealRate () . It should only be called once per payload .
func (ps *rateLimiter) Permits(n int64) bool {
	if n <= 0 {
		return true 
	}
	keep := true
	ps.mu.Lock()
	if ps.realRateLocked() > ps.stats.TargetRate {
		keep = false
		ps.stats.RecentTracesDropped += float64(n)
	}
	ps.stats.RecentPayloadsSeen++
	ps.stats.RecentTracesSeen += float64(n)
	ps.mu.Unlock()
	if !keep {
		log.Debugf("Rate limiting at rate %.2f dropped payload with %d traces", ps.TargetRate(), n)
	}
	return keep
}
func ( ps * rateLimiter ) Permits ( n int64 ) bool { if n <= 0 { return true } keep := true ps . mu . Lock ( ) if ps . realRateLocked ( ) > ps . stats . TargetRate { keep = false ps . stats . RecentTracesDropped += float64 ( n ) } ps . stats . RecentPayloadsSeen ++ ps . stats . RecentTracesSeen += float64 ( n ) ps . mu . Unlock ( ) if ! keep { log . Debugf ( " " , ps . TargetRate ( ) , n ) } return keep }
Permits reports wether the rate limiter should allow n more traces to
enter the pipeline.
Permits reports wether the rate limiter should allow n more traces to enter the pipeline .
// no sensible value in n, disable rate limiting // we're keeping more than the target rate, drop // this should be done *after* testing the real rate against the target rate, // otherwise we could end up systematically dropping the first payload.