diff --git a/src/Jaeger/UDPClient.php b/src/Jaeger/UDPClient.php index edcf283..7ca95ff 100644 --- a/src/Jaeger/UDPClient.php +++ b/src/Jaeger/UDPClient.php @@ -86,17 +86,19 @@ public function emitBatch(Batch $batch) $client = new AgentClient(null, $protocol); $client->emitBatch($batch); - $data = $buffer->getBuffer(); try { - socket_sendto( - $socket, - $data, - strlen($data), - 0, - $this->host, - $this->port - ); + while ($buffer->available()) { + $data = $buffer->read(65507); // max size of DGRAM payload https://stackoverflow.com/a/38742429 + socket_sendto( + $socket, + $data, + strlen($data), + ( $buffer->available() ) ? MSG_EOR : MSG_EOF, + $this->host, + $this->port + ); + } } finally { socket_close($socket); } diff --git a/tests/unit/Jaeger/UDPClientTest.php b/tests/unit/Jaeger/UDPClientTest.php index cd90824..7f2b2eb 100644 --- a/tests/unit/Jaeger/UDPClientTest.php +++ b/tests/unit/Jaeger/UDPClientTest.php @@ -93,7 +93,7 @@ public function testUsesSockets() $resource, Argument::type('string'), Argument::type('int'), - 0, + 512, '1.1.1.1', 1234 )->willReturn(123)->shouldBeCalledTimes(1);