-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpClient] Added TraceableHttpClient and WebProfiler panel #30494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/Symfony/Bundle/FrameworkBundle/DataCollector/HttpClientDataCollector.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/DataCollector/HttpClientDataCollector.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/DataCollector/HttpClientDataCollector.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/DataCollector/HttpClientDataCollector.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/DataCollector/HttpClientDataCollector.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/HttpClient/TraceableHttpClient.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/HttpClient/TraceableHttpClient.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/Resources/views/Collector/http_client.html.twig
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/HttpClient/TraceableHttpClient.php
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for that PR!
src/Symfony/Bundle/FrameworkBundle/DataCollector/HttpClientDataCollector.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/DataCollector/HttpClientDataCollector.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/DataCollector/HttpClientDataCollector.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/HttpClient/TraceableHttpClient.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/HttpClient/TraceableHttpClient.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/HttpClient/TraceableHttpClient.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/HttpClient/TraceableHttpClient.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/HttpClient/TraceableHttpClient.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/Resources/views/Collector/http_client.html.twig
Outdated
Show resolved
Hide resolved
Unlocked: FrameworkBundle integration PR is now merged, see #30419 |
@nicolas-grekas great news thanks! |
Thank you @nicolas-grekas for the OnProgress trick. |
src/Symfony/Bundle/FrameworkBundle/Resources/views/Collector/http_client.html.twig
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/Resources/config/http_client.xml
Outdated
Show resolved
Hide resolved
@jeremyFreeAgent Do you need any help on this? |
src/Symfony/Bundle/FrameworkBundle/HttpClient/TraceableHttpClient.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/HttpClient/TraceableHttpClient.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/DataCollector/HttpClientDataCollector.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/Resources/config/collectors.xml
Outdated
Show resolved
Hide resolved
Sorry guys for the delay. I've to focus on work these past weeks. I rework missing things that week. Thanks for the up @IonBazan |
Thing to consider: using |
6291ef0
to
744d361
Compare
I squashed all commits and made some changes to show what we can collect. For future PRs (let's make this one mergeable asap):
Note that it should be possible to collect a response that didn't complete yet (eg http_code is |
744d361
to
37b6851
Compare
37b6851
to
b4b2097
Compare
@nicolas-grekas Thank you for your changes. To be honest, I am not a fan of simply dumping all the collected data in profiler UI. For example, headers and performance information should be presented in more "structured" way. What do you think? I will add tests by the end of this week to make it mergeable 😄 |
@IonBazan sure, that's why it's the 1st item in my list for a future PRs. For headers, don't forget about redirections (try one you'll see what I mean when working on this). Waiting for the tests, thanks! |
Sometimes we need to make lot of external requests and the profiler can have a big scroll to show all the information of all requests. A simple suggestion is to add a collapse button (like in messager panel) in each collected request and start all of them collapsed excepted the first one of each configured http client. To help quickly see the status of each request (considering it is hide) you can add the status code before the method on request's title. |
One more idea added to my list above: add a copy-as-curl button next to each request in the profiler panel. |
@@ -1898,6 +1908,19 @@ private function registerHttpClientConfiguration(array $config, ContainerBuilder | ||
->setArguments([new Reference('http_client'), [$scope => $scopeConfig], $scope]); | ||
} | ||
|
||
if ($debug) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be interesting to add a tag to the service a this point, and to do the wiring logic in a compiler pass for all services having this tag. It will allow bundles to easily plug their own clients in the profiler.
For instance, we have this use case in API Platform.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm almost done except your comment.
To be sure to get your point I looked the Messenger stuff. So we are ok to add a tag to all http client here https://github.com/symfony/symfony/blob/4.4/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php#L1946-L1953
Like http_client.client
?
Then adding a HttpClientPass to make the call to the dataCollector in all service tagged with http_client.client
. (if data_collector is registered of course).
Right ?
@jeremyFreeAgent What's the next step? Can we merge something fast and iterate from there? |
|
||
<service id="debug.http_client" class="Symfony\Component\HttpClient\TraceableHttpClient" decorates="http_client"> | ||
<argument type="service" id="debug.http_client.inner" /> | ||
</service> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move these definitions to a http_client_debug.xml
file like done for other components.
Hi guys, I had a talk with @jeremyFreeAgent and I will help on this PR. Apparently, we only miss test to merge ? And then continue to work with small PR about refinements ? On my side what is the best way to work with this ongoing PR ? Start another PR by adding the jeremy's commit or we can do better ? |
you could create a new PR that would start with the commit in this PR, and add yours on top |
And please, can you take the remaining comments into accounts? |
Closing in favor of #33015. Thanks for your work @jeremyFreeAgent |
See also #33311 |
… panel (jeremyFreeAgent) This PR was merged into the 4.4 branch. Discussion ---------- [HttpClient] Added TraceableHttpClient and WebProfiler panel | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes <!-- please update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Replace #30494 I added : - tests - move debug services declaration in dedicated `http_client_debug.xml` file - rename stuff to follow messenger data collector stuff - add CompilerPass to allow bundle to trace their own http client I didn't add all @nicolas-grekas requests on UI profiler. I will continue to make more PR after this one. IMO everything looks fine to make a first merge except one strange behavior that I am not sure to get : When making a sub request : - we still have the http_client parent data. (like messenger, but currently I did not see anything in code that could avoid that, so different topic I guess). - The data collected are already "converted" to VarDumper data, so I have errors when trying to do all the unset stuff in the TraceableHttpClient. Is it for this reason, some collector use `lateCollect` ? Should we also move to lateCollect in the `HttpClientDataCollector` ? But I'm still new on this subject but glad to help, so feel free to request more changes ! Commits ------- 5164001 [HttpClient] Added TraceableHttpClient and WebProfiler panel
That PR adds TraceableHttpClient and the DataCollector.
Needs #30419 for the integration of HttpClient in FrameworkBundle.
Preview:
