Skip to content

Commit f45d808

Browse files
committed
review feedback
1 parent 201b11e commit f45d808

File tree

5 files changed

+21
-3
lines changed

5 files changed

+21
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66

77
- The real request method and target url are now displayed in the profiler.
88
- Support the cache plugin configuration for `respect_response_cache_directives`.
9+
- Extended WebProfilerToolbar item to list request with details.
910

1011
### Changed
1112

1213
- The profiler design has been updated.
14+
- Removed stopwatch-plugin in favor of `ProfileClient`.
1315

1416
### Deprecated
1517

Collector/ProfileClient.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ class ProfileClient implements HttpClient, HttpAsyncClient
4141
*/
4242
private $stopwatch;
4343

44+
/**
45+
* @var array
46+
*/
47+
private $eventNames = [];
48+
4449
/**
4550
* @param HttpClient|HttpAsyncClient $client The client to profile. Client must implement both HttpClient and
4651
* HttpAsyncClient interfaces.
@@ -81,6 +86,7 @@ function (ResponseInterface $response) use ($event, $stack) {
8186

8287
return $response;
8388
}, function (\Exception $exception) use ($event, $stack) {
89+
$event->stop();
8490
$this->collectExceptionInformations($exception, $event, $stack);
8591

8692
throw $exception;
@@ -173,6 +179,14 @@ private function collectExceptionInformations(\Exception $exception, StopwatchEv
173179
*/
174180
private function getStopwatchEventName(RequestInterface $request)
175181
{
176-
return sprintf('%s %s', $request->getMethod(), $request->getUri()->__toString());
182+
$name = sprintf('%s %s', $request->getMethod(), $request->getUri());
183+
184+
if (isset($this->eventNames[$name])) {
185+
$name .= sprintf(' [#%d]', ++$this->eventNames[$name]);
186+
} else {
187+
$this->eventNames[$name] = 1;
188+
}
189+
190+
return $name;
177191
}
178192
}

Collector/ProfileClientFactory.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class ProfileClientFactory implements ClientFactory
4141
* @param ClientFactory|callable $factory
4242
* @param Collector $collector
4343
* @param Formatter $formatter
44+
* @param Stopwatch $stopwatch
4445
*/
4546
public function __construct($factory, Collector $collector, Formatter $formatter, Stopwatch $stopwatch)
4647
{

DependencyInjection/HttplugExtension.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,7 @@ private function configureAutoDiscoveryFactory(ContainerBuilder $container, $dis
556556
$factory,
557557
new Reference('httplug.collector.collector'),
558558
new Reference('httplug.collector.formatter'),
559+
new Reference('debug.stopwatch'),
559560
]);
560561
$factory = new Reference($factoryServiceId);
561562
}

Resources/views/webprofiler.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
<td>{{ stack.requestMethod }}</td>
3333
{% set target = stack.requestTarget %}
3434
<td title="{{ target }}">{{ target|length > 30 ? target[:30] ~ '...' : target }}</td>
35-
<td>{{ stack.duration|number_format ~ ' ms'}}</td>
36-
<td>{{ stack.failed ? 'FAILED' : stack.responseCode }}</td>
35+
<td>{{ stack.duration == 0 ? 'n/a' : stack.duration|number_format ~ ' ms'}}</td>
36+
<td>{{ stack.failed ? 'FAILED' : stack.responseCode|default('n/a') }}</td>
3737
</tr>
3838
{% endfor %}
3939
</tbody>

0 commit comments

Comments
 (0)