Actually defines the sampling rate used by the service.
If set to 0.1, the service will automatically discard 10%
of the incoming metrics. It will also automatically flag these
as sampled data to statsd.

@param float $samplingRate
968032
public function setSamplingRate($samplingRate)
    {
        if ($samplingRate <= 0.0 || 1.0 < $samplingRate) {
            throw new \LogicException('Sampling rate shall be within ]0, 1]');
        }
        $this->samplingRate = $samplingRate;
        $this->samplingFunction = function($min, $max){
            return rand($min, $max);
        };
    }
576053
public function gauge($metric, $level, array $tags = array(), $sampleRate = AbstractMetric::DEFAULT_SAMPLE_RATE)
    {
        return new Gauge($this->prefix($metric), $level, array_merge($this->defaultTags, $tags), $sampleRate);
    }
639694
static function timer_stop($timer)
    {
        $time = microtime(true);
        if (isset(self::$timers[$timer]))
        {
            if (self::$timers[$timer]["started"])
            {
                if ( function_exists('getrusage'))
                {
                    /// @todo measure resource usage
                }
                self::$timers[$timer]["started"] = false;
                self::$timers[$timer]["value"] = $time - self::$timers[$timer]["value"];
            }
        }
        return false;
    }
414695
public function set($stat, $value, $sampleRate = 1, array $tags = null)
    {
        return $this->send(array($stat => "$value|s"), $sampleRate, $tags);
    }
475054
public static Sampler create(final float rate) {
        if (rate == 0) {
            return NEVER_SAMPLE;
        }
        if (rate == 1.0) {
            return ALWAYS_SAMPLE;
        }
        if (rate < 0.01f || rate > 1) {
            throw new IllegalArgumentException("rate should be between 0.01 and 1: was " + rate);
        }
        return new CountingSampler(rate);
    }
668019
def samplerate(self):
        """"""
        if hasattr(self.mgfile.info, 'sample_rate'):
            return self.mgfile.info.sample_rate
        elif self.type == 'opus':
            # Opus is always 48kHz internally.
            return 48000
        return 0
1149551
public function gauge($stat, $value, $sampleRate = 1, array $tags = null)
    {
        return $this->send(array($stat => "$value|g"), $sampleRate, $tags);
    }
645
func (mc *MetricsConfiguration) SampleRate() float64 {
	if mc.SamplingRate > 0.0 && mc.SamplingRate <= 1.0 {
		return mc.SamplingRate
	}
	return defaultSamplingRate
}
1271880
protected function setBitrate($bitrate)
	{
		if ( ! is_numeric($bitrate) || $bitrate < 0)
		{
			throw new \InvalidArgumentException('Wrong bitrate value.');
		}
		
		$this->bitrate = (int) $bitrate;
		
		return $this;
	}
666742
public function gauge($metric, $level, array $tags = array(), $sampleRate = AbstractMetric::DEFAULT_SAMPLE_RATE)
    {
        try {
            $this->sendMetric($this->metricFactory->gauge($metric, $level, $tags, $sampleRate));
        } catch (\Exception $exception) {
            $this->logException($exception);
        }

        return $this;
    }
1203401
public function formatTaxRate($rate)
    {
        return $rate != intval($rate) ? self::formatAsDecimal($rate, 1) : self::formatAsDecimal($rate, 0);
    }
1224840
def count(self, stats, value, sample_rate=1):
        
        self.update_stats(stats, value, self.SC_COUNT, sample_rate)
706067
protected static function setSampled($sampler)
    {
        if ($sampler === null) {
            static::$sampled = true;
            return null;
        }

        if (is_bool($sampler)) {
            static::$sampled = $sampler;
            return null;
        }

        if (!is_bool($sampler) && !($sampler instanceof Sampler)) {
            throw new \InvalidArgumentException('$sampler must be instance of Sampler or boolean');
        }

        static::$sampled = $sampler->isSampled();
        return null;
    }
677826
protected function calculate_sample($sampleid, $samplesorigin, $starttime = false, $endtime = false) {
        $user = $this->retrieve('user', $sampleid);
        return ($user->trackforums) ? self::get_max_value() : self::get_min_value();
    }
1293404
public static function run($size, &$c1, &$c2)
    {
        if( $size > 0 )
        {
            if( $size <= $c2 )
            {
                $rate = $c2 / $size; $c2 = $size; $c1 = $c1 / $rate;
            }
            else
            {
                $rate = $size / $c2; $c2 = $size; $c1 = $c1 * $rate;
            }
        }
    }
674948
def gauge(self, stat, value, sample_rate=1):
        
        stats = {stat: "%f|g" % value}
        self.send(stats, sample_rate)
754493
public boolean setSampleRate(int rate) {
    boolean result = (rate <= MAX_SAMPLE_RATE && rate >= MIN_SAMPLE_RATE);
    sampleRate = rate;
    return result;
  }