Skip to content

Commit b024423

Browse files
authored
Merge pull request #288 from oliverde8/fix/async-profiler
Fix wrong duration calculation for asynchronous calls
2 parents e055018 + 4328a3e commit b024423

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Collector/ProfileClient.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,14 @@ public function sendAsyncRequest(RequestInterface $request)
8686

8787
$onFulfilled = function (ResponseInterface $response) use ($event, $stack) {
8888
$this->collectResponseInformations($response, $event, $stack);
89+
$event->stop();
8990

9091
return $response;
9192
};
9293

9394
$onRejected = function (\Exception $exception) use ($event, $stack) {
9495
$this->collectExceptionInformations($exception, $event, $stack);
96+
$event->stop();
9597

9698
throw $exception;
9799
};
@@ -100,8 +102,11 @@ public function sendAsyncRequest(RequestInterface $request)
100102

101103
try {
102104
return $this->client->sendAsyncRequest($request)->then($onFulfilled, $onRejected);
103-
} finally {
105+
} catch (\Exception $e) {
104106
$event->stop();
107+
108+
throw $e;
109+
} finally {
105110
if ($activateStack) {
106111
//We only activate the stack when created by the StackPlugin.
107112
$this->collector->activateStack($stack);

0 commit comments

Comments
 (0)