public function postExecuteRequest(PostExecuteRequest $event)
 {
     $timeElapsed = TimeUtil::getElapsedTime($this->currentStartTime);
     if (!isset($this->currentRequest)) {
         throw new \RuntimeException('Request not set');
     }
     if ($this->currentRequest !== $event->getRequest()) {
         throw new \RuntimeException('Requests differ');
     }
     $this->addStat(new Stat(StatsdDataInterface::STATSD_METRIC_TIMING, $timeElapsed, array('solarium_endpoint' => $this->currentEndpoint->getKey(), 'solarium_request_method' => strtolower($event->getRequest()->getMethod()), 'solarium_response_status' => sprintf('%d', $event->getResponse()->getStatusCode()))));
     $this->currentRequest = null;
     $this->currentStartTime = null;
     $this->currentEndpoint = null;
 }
Пример #2
0
 /**
  * Add an endpoint
  *
  * Supports a endpoint instance or a config array as input.
  * In case of options a new endpoint instance wil be created based on the options.
  *
  * @throws InvalidArgumentException
  * @param  Endpoint|array           $endpoint
  * @return self                     Provides fluent interface
  */
 public function addEndpoint($endpoint)
 {
     if (is_array($endpoint)) {
         $endpoint = new Endpoint($endpoint);
     }
     $key = $endpoint->getKey();
     if (0 === strlen($key)) {
         throw new InvalidArgumentException('An endpoint must have a key value');
     }
     //double add calls for the same endpoint are ignored, but non-unique keys cause an exception
     //@todo add trigger_error with a notice for double add calls?
     if (array_key_exists($key, $this->endpoints) && $this->endpoints[$key] !== $endpoint) {
         throw new InvalidArgumentException('An endpoint must have a unique key');
     } else {
         $this->endpoints[$key] = $endpoint;
         // if no default endpoint is set do so now
         if (null == $this->defaultEndpoint) {
             $this->defaultEndpoint = $key;
         }
     }
     return $this;
 }