Ejemplo n.º 1
0
 /**
  * Send data via UDP
  *
  * @param ProfilerData $data
  */
 public function send(ProfilerData $data)
 {
     list($host, $port) = $this->getEndpoint($data->getEngine());
     if (!$host || !$port) {
         return;
     }
     $profile = $data->getProfile();
     $sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
     $plength = 0;
     $packet = "";
     foreach ($data->getEntries() as $name => $pfdata) {
         foreach (array('cpu', 'cpu_sq', 'real', 'real_sq') as $key) {
             if (!isset($pfdata[$key])) {
                 $pfdata[$key] = -1;
             }
         }
         $pfline = sprintf("%s %s %d %f %f %f %f %s\n", $profile, "-", $pfdata['count'], $pfdata['cpu'], $pfdata['cpu_sq'], $pfdata['real'], $pfdata['real_sq'], $name);
         $length = strlen($pfline);
         if ($length + $plength > self::LESS_THAN_MTU) {
             socket_sendto($sock, $packet, $plength, 0, $host, $port);
             $packet = "";
             $plength = 0;
         }
         $packet .= $pfline;
         $plength += $length;
     }
     socket_sendto($sock, $packet, $plength, 0x100, $host, $port);
 }
Ejemplo n.º 2
0
 /**
  * Send data via Scribe
  *
  * @param ProfilerData $data
  */
 public function send(ProfilerData $data)
 {
     if (!$this->checkDependencies()) {
         return;
     }
     $scribeKey = $this->getScribeKey($data->getEngine());
     $data = array('time' => microtime(true), 'engine' => $data->getEngine(), 'profile' => $data->getProfile(), 'context' => Transaction::getAttributes(), 'request' => $data->getRequest(), 'entries' => $data->getEntries());
     $data = json_encode($data);
     try {
         WScribeClient::singleton($scribeKey)->send($data);
     } catch (TException $e) {
         Wikia::log(__METHOD__, 'scribeClient exception', $e->getMessage());
     }
 }