23 use Liuggio\StatsdClient\StatsdClient;
24 use Liuggio\StatsdClient\Entity\StatsdData;
25 use Liuggio\StatsdClient\Entity\StatsdDataInterface;
61 if ( fnmatch( $pattern, $item->getKey(), FNM_NOESCAPE ) ) {
62 $item->setSampleRate( $item->getSampleRate() * $rate );
83 if ( !is_array(
$data ) ) {
90 if ( !( $item instanceof StatsdDataInterface ) ) {
91 throw new InvalidArgumentException(
92 'SamplingStatsdClient does not accept stringified messages' );
103 if ( $this->getReducePacket() ) {
110 $fp = $this->getSender()->open();
114 foreach (
$data as $message ) {
115 $written += $this->getSender()->write( $fp, $message );
117 $this->getSender()->close( $fp );
118 }
catch ( Exception
$e ) {
133 $mt_rand_max = mt_getrandmax();
135 $samplingRate = $item->getSampleRate();
136 if ( $samplingRate <= 0.0 || $samplingRate > 1.0 ) {
137 throw new LogicException(
'Sampling rate shall be within ]0, 1]' );
140 $samplingRate === 1 ||
141 ( mt_rand() / $mt_rand_max <= $samplingRate )
153 if ( !$this->getFailSilently() ) {