Example #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;
 }
Example #2
0
 /**
  * @dataProvider providerNamespace
  * @param mixed $namespace
  */
 public function testSeNamespace($namespace)
 {
     $configuration = new Configuration();
     $configuration->setNamespace($namespace);
     $this->assertSame($namespace, $configuration->getNamespace(), 'Unexpected namespace.');
 }