RestApiClient: use Benchmark

This commit is contained in:
Thomas Gelf 2015-11-09 18:31:26 +01:00
parent b5ba2b7da9
commit e302632196
1 changed files with 3 additions and 0 deletions

View File

@ -2,6 +2,7 @@
namespace Icinga\Module\Director\Core; namespace Icinga\Module\Director\Core;
use Icinga\Application\Benchmark;
use Exception; use Exception;
class RestApiClient class RestApiClient
@ -78,10 +79,12 @@ class RestApiClient
); );
$context = stream_context_create($opts); $context = stream_context_create($opts);
Benchmark::measure('Rest Api, sending ' . $url);
$res = file_get_contents($this->url($url), false, $context); $res = file_get_contents($this->url($url), false, $context);
if (substr(array_shift($http_response_header), 0, 10) !== 'HTTP/1.1 2') { if (substr(array_shift($http_response_header), 0, 10) !== 'HTTP/1.1 2') {
throw new Exception($res); throw new Exception($res);
} }
Benchmark::measure('Rest Api, got response');
if ($raw) { if ($raw) {
return $res; return $res;
} else { } else {