From d808f797eb379cdb7a1951b3f717370a18762170 Mon Sep 17 00:00:00 2001 From: Marcel Hernandez Date: Wed, 10 Apr 2019 15:32:09 +0200 Subject: [PATCH 1/2] collect appconnect_time --- src/Handler/CurlFactory.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Handler/CurlFactory.php b/src/Handler/CurlFactory.php index 7da4af8d5..e349bb4c4 100644 --- a/src/Handler/CurlFactory.php +++ b/src/Handler/CurlFactory.php @@ -120,6 +120,7 @@ public static function finish( private static function invokeStats(EasyHandle $easy) { $curlStats = curl_getinfo($easy->handle); + $curlStats['appconnect_time'] = curl_getinfo($easy->handle, CURLINFO_APPCONNECT_TIME); $stats = new TransferStats( $easy->request, $easy->response, @@ -139,6 +140,7 @@ private static function finishError( $ctx = [ 'errno' => $easy->errno, 'error' => curl_error($easy->handle), + 'appconnect_time' => curl_getinfo($easy->handle, CURLINFO_APPCONNECT_TIME), ] + curl_getinfo($easy->handle); $ctx[self::CURL_VERSION_STR] = curl_version()['version']; $factory->release($easy); From 40aa8b1642762ed00ea7cb4a5d4aa8219126c87b Mon Sep 17 00:00:00 2001 From: Marcel Hernandez Date: Wed, 10 Apr 2019 15:46:08 +0200 Subject: [PATCH 2/2] test presence of appconnect_time key in curl stats array --- tests/Handler/CurlFactoryTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/Handler/CurlFactoryTest.php b/tests/Handler/CurlFactoryTest.php index af52c58d2..d1e4e9980 100644 --- a/tests/Handler/CurlFactoryTest.php +++ b/tests/Handler/CurlFactoryTest.php @@ -685,6 +685,7 @@ public function testInvokesOnStatsOnSuccess() (string) $gotStats->getRequest()->getUri() ); $this->assertGreaterThan(0, $gotStats->getTransferTime()); + $this->assertArrayHasKey('appconnect_time', $gotStats->getHandlerStats()); } public function testInvokesOnStatsOnError() @@ -711,6 +712,7 @@ public function testInvokesOnStatsOnError() ); $this->assertInternalType('float', $gotStats->getTransferTime()); $this->assertInternalType('int', $gotStats->getHandlerErrorData()); + $this->assertArrayHasKey('appconnect_time', $gotStats->getHandlerStats()); } public function testRewindsBodyIfPossible()