示例#1
0
 /**
  * @return $messages
  */
 public function sendStats()
 {
     $namespace = $this->configuration->getNamespace();
     $socketUrl = sprintf('udp://' . $this->configuration->getHost());
     $messages = array();
     foreach ($this->stats as $key => $stat) {
         $msg = $namespace . '.' . $this->statToString($stat);
         $messages[] = $msg;
         if (null !== $this->logger) {
             $this->logger->info('Sending metrics: ' . $msg);
         }
         $socket = fsockopen($socketUrl, $this->configuration->getPort());
         fwrite($socket, $msg);
         fclose($socket);
         unset($this->stats[$key]);
     }
     return $messages;
 }
示例#2
0
 public function testGetDefaultPort()
 {
     $configuration = new Configuration();
     $this->assertSame(Configuration::DEFAULT_PORT, $configuration->getPort(), 'Unexpected port.');
 }