public function testRequestMetrics() { $action = "GetObject"; $metricName = RequestMetrics::EXECUTION_TIME; $requestMetrics = new RequestMetrics($action); $requestMetrics->startEvent($metricName); sleep(1); $requestMetrics->endEvent($metricName); $clientMetrics = $requestMetrics->toClientMetrics(); $metrics = $clientMetrics->getMetrics(); $this->assertEquals(1, count($metrics)); $this->assertEquals("GetObject.ExecutionTime", $metrics[0]->getMetricName()); $this->assertEquals("Latency", $metrics[0]->getMetricType()); }
private function invoke($action, $uri, $headers, $method, $expects, $payload) { if ($this->fds_config->isMetricsEnabled()) { $request_metrics = new RequestMetrics($action); $request_metrics->startEvent(RequestMetrics::EXECUTION_TIME); } $request = null; switch ($method) { case Http::GET: $request = Request::get($uri); break; case Http::PUT: $request = Request::put($uri, $payload); break; case Http::POST: $request = Request::post($uri, $payload); break; case Http::DELETE: $request = Request::delete($uri); break; case Http::HEAD: $request = Request::head($uri); } if ($expects != null) { $request = $request->expects($expects); } $response = $request->addHeaders($headers)->retry($this->fds_config->getRetry())->timeout($this->fds_config->getConnectionTimeoutSecs())->send(); if ($this->fds_config->isMetricsEnabled()) { $request_metrics->endEvent(RequestMetrics::EXECUTION_TIME); $this->metrics_collector->collect($request_metrics); } return $response; }