Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[WebProfilerBundle] Generate profiler urls with an useful panel #32491

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

Closed
wants to merge 1 commit into from

Conversation

fancyweb
Copy link
Contributor

@fancyweb fancyweb commented Jul 10, 2019

Q A
Branch? 4.4
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? no
Fixed tickets -
License MIT
Doc PR -

So I did this quickly to get feedback. It could probably be splitted for clarity.

The goal of this work is to provide a better DX with Ajax requests in the WDT.

Having a private profile stack allow us to pass it to the WebDebugToolbarListener to process collected data and to directly build the profiler link with the useful panel.

I think that adding a direct link to the dumps panel when there are dumps in an Ajax request would be very useful.

It would also impove the work done in #26665 by being sure there is actually an exception in the exception panel.

Since all impacted classes were made @final in 4.3, it is easy to drop the current behavior (ie remove the double usage of the $profiles / ProfileStack in the ProfilerListener and the optional ProfileStack in the WebDebugToolbarListener) and to fully switch to the new one in 5.0.

👍 or 👎 ?

@nicolas-grekas
Copy link
Member

Can you please share a screenshot (with a short animation if that makes sense?) This always helps a lot when improving the profiler.

@fancyweb
Copy link
Contributor Author

fancyweb commented Jul 11, 2019

Sure, considering there is a dump in the code :

Currently :
screenshot_01

After :
screenshot_03

If there is a dump, it's very likely that the user wants to see it. It saves one click.

@fancyweb fancyweb force-pushed the profile-stack branch 2 times, most recently from 62adb1f to bc83241 Compare July 27, 2019 10:52
@fancyweb
Copy link
Contributor Author

Just added tests.

@nicolas-grekas
Copy link
Member

Can we do this using a special debugging header? If yes, wouldn't it make the implementation simpler?

@fancyweb
Copy link
Contributor Author

fancyweb commented Aug 1, 2019

We can technically do it with special headers. It heavily reduces the amount of added code.
However I see at least three problems :

  1. Adding a random header in the collectors looks bad. It adds this logic in the HttpKernel component, thus polluting the component while it's just for us and our web profiler bundle.
  2. By using a header, we lose the control of which panels can be accessed directly : any 3rd party collector can force the redirection to its panel if it overrides the header and is "collected" last.
  3. Managing the priority of the preferred panel (exception > all) becomes hard because collectors can be processed in any order + their name is dynamic (the collector name === the panel name)

@fancyweb
Copy link
Contributor Author

fancyweb commented Sep 4, 2019

Friendly ping @nicolas-grekas, @ro0NL, @BoShurik, @ismail1432 and @fabpot (since you resolved a discussion), is this going anywhere? I deeply think it's useful and would like to see this in 4.4.

The only thing left to do is to manage the constructor arguments of WebDebugToolbarListener to deprecate not passing a ProfileStack as a 2nd mandatory argument, although I don't understand why it's needed since the class is @final since Symfony 4.3 and according to https://symfony.com/doc/current/contributing/code/bc.html that means it is really final in the next major version (and so the promise does not apply anymore).

@stof
Copy link
Member

stof commented Sep 4, 2019

I also suggest rewording the PR title (which will appear in generated changelogs) and the commit message to talk about the feature being implemented. The profile stack is not the feature, but an internal implementation detail (proof is that the class is @internal)

@fancyweb fancyweb changed the title [HttpKernel][WebProfilerBundle] Profile stack [WebProfilerBundle] Generate profiler urls with an useful panel Sep 4, 2019
@javiereguiluz
Copy link
Member

@fancyweb thanks for working on this! About the new feature, I like it because it's a nice little DX improvement.

About the technical details, I don't have a strong opinion. I'd like to add less code to implement this ... but this comment shows some compelling arguments against that ... so I'm divided.

@nicolas-grekas
Copy link
Member

I still feel like that's a lot of code for the use case.
Alternative idea: link to ?panel=auto and let that trigger a redirect to the best panel for the corresponding profile. Up to us to implement what "best" means here, eg the dump, or the error page, etc.

@fancyweb
Copy link
Contributor Author

@nicolas-grekas Your alternative idea seems very good actually. I will give it a try quickly.

@stof
Copy link
Member

stof commented Oct 1, 2019

I suggest closing this PR in favor of #33783, which has several advantages IMO:

  • it adds logic when someone clicks on the link, rather than adding more work in the listener running for all responses
  • the listener runs before the profile is complete (many collectors are collecting things only during kernel.terminate thanks to lateCollect), meaning that its guessing is based on incomplete data. On the other hand, the controller displaying a panel has the full data of the profile.

@stof
Copy link
Member

stof commented Oct 1, 2019

and btw, putting it in the controller also allows using this guessing in other links (we could make search results use it too).

@fancyweb fancyweb closed this Oct 1, 2019
@fancyweb fancyweb deleted the profile-stack branch October 1, 2019 11:37
nicolas-grekas added a commit that referenced this pull request Oct 2, 2019
…el by default (fancyweb)

This PR was merged into the 4.4 branch.

Discussion
----------

[WebProfilerBundle] Try to display the most useful panel by default

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | yes
| Tickets       | -
| License       | MIT
| Doc PR        | -

Alternative to #32491, the goal stays the same.

I think reserving a data collector name is fine, isn'it ? It's not likely that end users use this name (that's why I added an underscore) + shouldn't be hard for them to just rename it.

I don't think adding a configuration option to toggle the "_best" behavior is useful, should be by default for DX IMHO.

Not adding an extension point for now (for end users to set their panel as the "best"), maybe later if someone request it?

Commits
-------

a45dd98 [WebProfilerBundle] Try to display the most useful panel by default
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.4 Oct 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.