Skip to content
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

Improved collector #84

Merged
merged 1 commit into from
Jul 18, 2016
Merged

Improved collector #84

merged 1 commit into from
Jul 18, 2016

Conversation

Nyholm
Copy link
Member

@Nyholm Nyholm commented Jul 3, 2016

This PR is work in progress. I just want to show the progress. Please try it out and give me feedback. I believe the collector and extensions work properly. The work that is left is on the design and display of things.

Related to #26

TODO

  • Only show the first request in the stack by default
  • Show rest of the stack when you click "Show all"
  • Hide the body of the request by default and add a "Show body" button.
  • Add nice design
  • Maybe put different adapters on different pages. Design it like the translation "Translated"/"Fallback"/"Not translated"

@dbu
Copy link
Collaborator

dbu commented Jul 4, 2016

great work @Nyholm !

how do you display the information? we will end up with a lot of information if several plugins are active...

@Nyholm
Copy link
Member Author

Nyholm commented Jul 4, 2016

Thank you.

Im not too sure at the moment to be honest... I'll look at Symfony pages and try to do something similar.

@dbu
Copy link
Collaborator

dbu commented Jul 4, 2016

okay. maybe for each request show the final version that was sent / received by default, and have little tabs to see the other versions between plugins?

@Nyholm
Copy link
Member Author

Nyholm commented Jul 13, 2016

This PR is ready for a review. Im not sure I can make the design look better.

@Nyholm Nyholm changed the title [WIP] Improved collector Improved collector Jul 13, 2016
@Nyholm
Copy link
Member Author

Nyholm commented Jul 13, 2016

Here are some screenshots

First view

screen shot 2016-07-13 at 21 06 29

Show a stack

screen shot 2016-07-13 at 21 06 59

Show body

screen shot 2016-07-13 at 21 07 14

Show errors by the error plugin

screen shot 2016-07-13 at 21 40 48

Show errors from the http client

screen shot 2016-07-13 at 21 41 20

@Nyholm
Copy link
Member Author

Nyholm commented Jul 13, 2016

*
* @return ClientDataProvider
*/
public function setRequests($requests)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe setters should be removed here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...and the getters... They are not used. Only get*Stack is used.

@joelwurtz
Copy link
Member

Not sure if it's possible to add this here, but i would love to have an option to show request and response content as sometime you want to debug the content of the request you send or the response you receive.

However this can have memory and latency issue for big request / response (i.e. files), so it would be better to add an option in the config (which default to false) for allowing this feature.

WDYT ?

@Nyholm
Copy link
Member Author

Nyholm commented Jul 15, 2016

request and response content? Do you mean the HTTP message body? If so, you can toggle that in the top right corner. Look at image 3. =)

@joelwurtz
Copy link
Member

Who didn't see that, is this an option for the debugger ? And also does it show also the request body ?

@Nyholm
Copy link
Member Author

Nyholm commented Jul 15, 2016

I use the new FullHttpMessageFormatter to capture the full HTTP message for both requests and responses.

You may configure the FullHttpMessageFormatter to a different limit on the body. Default is 1000 chars. To change that construction parameter is not supported in this PR. I'll leave that for a future update.

@joelwurtz
Copy link
Member

Just see the formatter and how the request / response is read.

As far as i have see, this formatter mess up with the stream, as __toString is called and the stream is not rewind so the content is retrieve only in the first stream ?

(I may have miss something again ^^)

@Nyholm
Copy link
Member Author

Nyholm commented Jul 15, 2016

I believe you are correct. I created an issue.

So streams should always be rewinded after we read them?

@joelwurtz
Copy link
Member

So streams should always be rewinded after we read them?

Depends if the stream is rewindable or not, if not we must buffer the stream into memory and replace it in the request and this will have a huge impact on performance IMO

@Nyholm
Copy link
Member Author

Nyholm commented Jul 15, 2016

Who is using streams that you cant rewind (not seekable) in this case?

Guzzle has PumpStream, NoSeekStream, BufferStream and Zend has CallbackStream which never are seekable.

I think we should add allow to opt-out of this if there is a major performance impact.

@dbu
Copy link
Collaborator

dbu commented Jul 15, 2016

This looks really cool! Some of those screenshots could be used to illustrate the plugin concept in the documentation :-)

regarding streams: i suggest we default to not read anything of the body, but instead have a hint in the debug output that it can be enabled. i would usually expect people to reproduce a call with curl if they want to see the response. (i think we discussed showing a curl command line for a request which would make this trivial - but that is out of scope for this PR)

reading the body means messing with streams, which can pose problems or huge slowdowns if there is larger http bodies involved. if its no bid effort, i am ok to keep the option available, but disabled by default.

@sagikazarmark
Copy link
Member

i think we discussed showing a curl command line for a request

That would be a cURL formatter in the message package: php-http/message#19

reading the body means messing with streams, which can pose problems or huge slowdowns if there is larger http bodies involved. if its no bid effort, i am ok to keep the option available, but disabled by default.

This is not always possible. In some cases the stream is read-once. We need to provide an alternative stream in that case with the original content.

@dbu
Copy link
Collaborator

dbu commented Jul 15, 2016 via email

@sagikazarmark
Copy link
Member

As @Nyholm said copying is not an option, because the request is immutable. So non-rewindable streams should never be read, otherwise users can optionally turn on this feature.

@@ -68,7 +68,7 @@ public static function createFromCollectedData(array $data)

/**
* @param array $messages is an array with keys 'failure', 'request' and 'response' which hold requests for each call to
* sendRequest and for each depth.
* sendRequest and for each depth
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is a solution. Normally we need that period. See php-http/message#48

@sagikazarmark
Copy link
Member

@Nyholm it seems symfony changed their CS: symfony/symfony#19198

However, the fixer still seems to be buggy, so I would stick with the full stop everywhere and change it later if necessary. I updated the master branch with the latest styleci config.

@Nyholm
Copy link
Member Author

Nyholm commented Jul 15, 2016

So, No more CS changes in this PR?

Since the merge of php-http/message#47 is there anything left to be done in this PR?

@sagikazarmark
Copy link
Member

After merging #86 can you please rebase from master and revert 4c33132?

@sagikazarmark
Copy link
Member

UX: Request 0 -> Request #0

Looks better IMHO, WDYT?

@Nyholm
Copy link
Member Author

Nyholm commented Jul 15, 2016

Sure

@@ -0,0 +1,132 @@

Copy link
Member

@sagikazarmark sagikazarmark Jul 15, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why leading newlines?

@sagikazarmark
Copy link
Member

As always, I am the style guy 😉 Can you please take a look at my comments? I would leave the technical review to @dbu and @joelwurtz as I haven't really followed this conversation.

@sagikazarmark
Copy link
Member

Can you rebase from master?

@Nyholm
Copy link
Member Author

Nyholm commented Jul 15, 2016

This PR is now rebased and I've addressed all your comments except for the one with the Javascript indentation.

@sagikazarmark
Copy link
Member

So is this ready for merging then?

@Nyholm
Copy link
Member Author

Nyholm commented Jul 15, 2016

If @joelwurtz and/or @dbu says it is okey, then it's ready to merge IMHO.

@sagikazarmark
Copy link
Member

Ok

@@ -16,11 +16,12 @@
* @param Plugin[] $plugins
* @param ClientFactory $factory
* @param array $config
* @param array $pluginClientOptions
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a short text that explains the $config and $pluginClientOptions? as its two sets of options, it would help to know what each is to keep them cleanly separated. saying that $pluginClientOptions is forwareded to PluginClient is good enough for me.

@dbu
Copy link
Collaborator

dbu commented Jul 18, 2016

looks good. mark had some comments about missing @inheritDoc or explanations on the methods, can you adress those as well please? and can you please squash the commits? then looks good to merge to me.

@Nyholm
Copy link
Member Author

Nyholm commented Jul 18, 2016

I believe I already have addressed Marks comments about @inhertdoc. They are just not marked as "comment on an outdated diff"

@Nyholm
Copy link
Member Author

Nyholm commented Jul 18, 2016

Rebased and ready for being merged

@dbu dbu merged commit 68ccd1e into master Jul 18, 2016
@dbu dbu deleted the dev-improved-collector branch July 18, 2016 07:32
@dbu
Copy link
Collaborator

dbu commented Jul 18, 2016

great job, thanks!

@Nyholm
Copy link
Member Author

Nyholm commented Jul 18, 2016

Thank you all for the reviews and feedback.

@sagikazarmark
Copy link
Member

Great job as always @Nyholm. Many thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants