// RequestSampler allows one to set the sampling decision based on the details
// found in the http.Request.
164896
func RequestSampler(sampleFunc func(r *http.Request) bool) ServerOption {
	return func(h *handler) {
		h.requestSampler = sampleFunc
	}
}
1086892
func (s *rateLimitingSampler) IsSampled(id TraceID, operation string) (bool, []Tag) {
	return s.rateLimiter.CheckCredit(1.0), s.tags
}
498173
func ParseSampleFormat(s string) SampleFormat {
	cstr := C.CString(s)
	defer C.free(unsafe.Pointer(cstr))
	return SampleFormat(C.pa_parse_sample_format(cstr))
}
1218347
func (s *Mp2Settings) SetSampleRate(v int64) *Mp2Settings {
	s.SampleRate = &v
	return s
}
525339
func NewConstSampler(sample bool) Sampler {
	tags := []Tag{
		{key: SamplerTypeTagKey, value: SamplerTypeConst},
		{key: SamplerParamTagKey, value: sample},
	}
	return &ConstSampler{Decision: sample, tags: tags}
}
919750
func (c *Memory) StartSampling(samplingInterval int, suppressRandomness bool) (*gcdmessage.ChromeResponse, error) {
	var v MemoryStartSamplingParams
	v.SamplingInterval = samplingInterval
	v.SuppressRandomness = suppressRandomness
	return c.StartSamplingWithParams(&v)
}
1260997
func (n *NATSStreamingRequesterFactory) GetRequester(num uint64) bench.Requester {
	return &natsStreamingRequester{
		url:         n.URL,
		clientID:    n.ClientID,
		payloadSize: n.PayloadSize,
		subject:     n.Subject + "-" + strconv.FormatUint(num, 10),
	}
}
306411
func (s *CreateSamplingRuleInput) SetSamplingRule(v *SamplingRule) *CreateSamplingRuleInput {
	s.SamplingRule = v
	return s
}
1154378
func (s *SynthesizeSpeechInput) SetSampleRate(v string) *SynthesizeSpeechInput {
	s.SampleRate = &v
	return s
}
230352
func (s *adaptiveSampler) Sample() bool {
	// adjust sampling rate whenever sample size is reached.
	var currentRate int
	if atomic.AddUint32(&s.counter, 1) == s.sampleSize { // exact match prevents
		atomic.StoreUint32(&s.counter, 0) // race is ok
		s.Lock()
		{
			d := time.Since(s.start).Seconds()
			r := float64(s.sampleSize) / d
			currentRate = int((float64(s.maxSamplingRate) * adaptiveUpperBoundFloat) / r)
			if currentRate > adaptiveUpperBoundInt {
				currentRate = adaptiveUpperBoundInt
			} else if currentRate < 1 {
				currentRate = 1
			}
			s.start = time.Now()
		}
		s.Unlock()
		atomic.StoreInt64(&s.lastRate, int64(currentRate))
	} else {
		currentRate = int(atomic.LoadInt64(&s.lastRate))
	}

	// currentRate is never zero.
	return currentRate == adaptiveUpperBoundInt || rand.Intn(adaptiveUpperBoundInt) < currentRate
}
41106
func (samplerOptions) SamplingRefreshInterval(samplingRefreshInterval time.Duration) SamplerOption {
	return func(o *samplerOptions) {
		o.samplingRefreshInterval = samplingRefreshInterval
	}
}
499033
func (s fixedSampler) Sample() bool {
	samplingPercent := int(s)
	return samplingPercent > 0 && (samplingPercent == 100 || rand.Intn(100) < samplingPercent)
}
1286685
func (m *Monitor) AddSampler(fn SamplerFunc) {
	m.lock.Lock()
	defer m.lock.Unlock()
	m.samplers = append(m.samplers, fn)
}
331540
func (c *CassandraRequesterFactory) GetRequester(uint64) bench.Requester {
	return &cassandraRequester{
		urls:        c.URLs,
		keyspace:    c.Keyspace,
		consistency: c.Consistency,
		statement:   c.Statement,
		values:      c.Values,
	}
}
54501
func (d *RecordDecoder) Samples(rec []byte, samples []RefSample) ([]RefSample, error) {
	dec := encoding.Decbuf{B: rec}

	if RecordType(dec.Byte()) != RecordSamples {
		return nil, errors.New("invalid record type")
	}
	if dec.Len() == 0 {
		return samples, nil
	}
	var (
		baseRef  = dec.Be64()
		baseTime = dec.Be64int64()
	)
	for len(dec.B) > 0 && dec.Err() == nil {
		dref := dec.Varint64()
		dtime := dec.Varint64()
		val := dec.Be64()

		samples = append(samples, RefSample{
			Ref: uint64(int64(baseRef) + dref),
			T:   baseTime + dtime,
			V:   math.Float64frombits(val),
		})
	}

	if dec.Err() != nil {
		return nil, errors.Wrapf(dec.Err(), "decode error after %d samples", len(samples))
	}
	if len(dec.B) > 0 {
		return nil, errors.Errorf("unexpected %d bytes left in entry", len(dec.B))
	}
	return samples, nil
}
241740
func (r *RedisRequesterFactory) GetRequester(uint64) bench.Requester {
	return &redisRequester{
		url:     r.URL,
		command: r.Command,
		args:    r.Args,
	}
}
1126963
func (u *User) RequestStats() {
	packet := MumbleProto.UserStats{
		Session: &u.Session,
	}
	u.client.Conn.WriteProto(&packet)
}