Skip to content

Commit

Permalink
Merge pull request #2284 from 1ma/collect_appconnect_time
Browse files Browse the repository at this point in the history
Collect appconnect_time in CurlFactory TransferStats
  • Loading branch information
sagikazarmark committed Apr 15, 2019
2 parents e21a982 + 40aa8b1 commit bf59542
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Handler/CurlFactory.php
Expand Up @@ -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,
Expand All @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions tests/Handler/CurlFactoryTest.php
Expand Up @@ -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()
Expand All @@ -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()
Expand Down

0 comments on commit bf59542

Please sign in to comment.