Skip to content

Commit ef26e93

Browse files
bug #49104 [HttpClient] Fix collecting data non-late for the profiler (nicolas-grekas)
This PR was merged into the 5.4 branch. Discussion ---------- [HttpClient] Fix collecting data non-late for the profiler | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #49096 | License | MIT | Doc PR | - `@silverbackdan` `@pforesi` could you please confirm that this fixes both your use cases? Commits ------- 3cb1d70 [HttpClient] Fix collecting data non-late for the profiler
2 parents 96cdc5c + 3cb1d70 commit ef26e93

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/Symfony/Component/HttpClient/DataCollector/HttpClientDataCollector.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,28 @@ public function registerClient(string $name, TraceableHttpClient $client)
3838
*/
3939
public function collect(Request $request, Response $response, \Throwable $exception = null)
4040
{
41+
$this->lateCollect();
4142
}
4243

4344
public function lateCollect()
4445
{
45-
$this->reset();
46+
$this->data['request_count'] = 0;
47+
$this->data['error_count'] = 0;
48+
$this->data += ['clients' => []];
4649

4750
foreach ($this->clients as $name => $client) {
4851
[$errorCount, $traces] = $this->collectOnClient($client);
4952

50-
$this->data['clients'][$name] = [
51-
'traces' => $traces,
52-
'error_count' => $errorCount,
53+
$this->data['clients'] += [
54+
$name => [
55+
'traces' => [],
56+
'error_count' => 0,
57+
],
5358
];
5459

60+
$this->data['clients'][$name]['traces'] = array_merge($this->data['clients'][$name]['traces'], $traces);
5561
$this->data['request_count'] += \count($traces);
56-
$this->data['error_count'] += $errorCount;
62+
$this->data['error_count'] += $this->data['clients'][$name]['error_count'] += $errorCount;
5763

5864
$client->reset();
5965
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy