16 public function testSampling( $data, $sampleRate, $seed, $expectWrite ) {
17 $sender = $this->getMockBuilder( SenderInterface::class )->getMock();
18 $sender->expects( $this->
any() )->method(
'open' )->will( $this->returnValue(
true ) );
20 $sender->expects( $this->once() )->method(
'write' )
21 ->with( $this->
anything(), $this->equalTo( $data ) );
23 $sender->expects( $this->never() )->method(
'write' );
25 if ( defined(
'MT_RAND_PHP' ) ) {
26 mt_srand( $seed, MT_RAND_PHP );
31 $client->send( $data, $sampleRate );
56 $matching =
new StatsdData();
57 $matching->setKey(
'foo.bar' );
58 $matching->setValue( 1 );
60 $nonMatching =
new StatsdData();
61 $nonMatching->setKey(
'oof.bar' );
62 $nonMatching->setValue( 1 );
64 $sender = $this->getMockBuilder( SenderInterface::class )->getMock();
65 $sender->expects( $this->
any() )->method(
'open' )->will( $this->returnValue(
true ) );
66 $sender->expects( $this->once() )->method(
'write' )->with( $this->
anything(),
67 $this->equalTo( $nonMatching ) );
70 $client->setSamplingRates( [
'foo.*' => 0.2 ] );
73 $client->send( $matching );
75 $client->send( $nonMatching );