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

Improve collector view #652

Merged
merged 18 commits into from
Aug 11, 2021

Conversation

Jean-Beru
Copy link
Contributor

@Jean-Beru Jean-Beru commented Oct 2, 2020

This PR makes the collector show execution time of commands. Style has been taken from DoctrineBundle and could be improved in future PR (eg: a better command display).

We may add a better command display later. Eg: db.User.find({ _id: 1 });.
image

Resources/views/Collector/mongodb.html.twig Outdated Show resolved Hide resolved
Resources/views/Collector/mongodb.html.twig Outdated Show resolved Hide resolved
Resources/views/Collector/mongodb.html.twig Outdated Show resolved Hide resolved
@Jean-Beru Jean-Beru force-pushed the feature/improve-collector-view branch from 87bd733 to 6e0bc70 Compare October 17, 2020 12:40
@stale
Copy link

stale bot commented Dec 11, 2020

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in a week if no further activity occurs. Thank you for your contributions.

@stale stale bot added Stale Issues that have not seen any activity in 30 days and removed Stale Issues that have not seen any activity in 30 days labels Dec 11, 2020
@Jean-Beru
Copy link
Contributor Author

Is there anything that I can do to make this PR OK ?

@alcaeus
Copy link
Member

alcaeus commented Dec 12, 2020

I don't have enough time to review things at the moment, so there isn't much you can do. I'll mark this so the bot doesn't keep reminding you that I don't have time 😞

@Jean-Beru
Copy link
Contributor Author

I totally understand. I thought that you were waiting for some changes. Good luck and happy holiday season 😉

Copy link
Member

@IonBazan IonBazan left a comment

Choose a reason for hiding this comment

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

@alcaeus This feature would quite useful to many people. I was actually starting working on something similar but then found this PR. Is there any chance you could find a moment to take a look on that again? 🙏🏻

DataCollector/CommandDataCollector.php Outdated Show resolved Hide resolved
Resources/views/Collector/mongodb.html.twig Show resolved Hide resolved
@Jean-Beru Jean-Beru force-pushed the feature/improve-collector-view branch from 99c7508 to 6874044 Compare June 11, 2021 13:10
@noniagriconomie
Copy link
Contributor

May I ask you some screenshots? I would definitly love to have this improved UI as well, thanks :)

@Jean-Beru
Copy link
Contributor Author

Of course, I have just updated PR's description.

composer.json Outdated Show resolved Hide resolved
Copy link
Member

@IonBazan IonBazan left a comment

Choose a reason for hiding this comment

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

Copy link
Member

@alcaeus alcaeus left a comment

Choose a reason for hiding this comment

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

LGTM with the email change reverted 😊

composer.json Outdated Show resolved Hide resolved
<td class="nowrap">{{ loop.index }}</td>
<td class="nowrap">{{ '%0.3f'|format(command.durationMicros / 1000) }} ms</td>
<td class="nowrap">{{ command.database }}</td>
<td>{{ command.command }}</td>
Copy link
Member

Choose a reason for hiding this comment

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

Raw JSONs are hard to read so I think we could add a collapsible pretty-print version of the command JSON here just like in ElasticaBundle: https://github.com/FriendsOfSymfony/FOSElasticaBundle/blob/master/src/Resources/views/Collector/elastica.html.twig#L129-L135

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What about decoding and encoding current value in template to keep canonical extended JSON format ? Like {{ data|json_decode|json_encode(constant('JSON_PRETTY_PRINT')) }}.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that makes sense 👍🏻

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. FYI, json_decode has been done in DataCollector since Twig does not provide a such filter, cf. twigphp/Twig#824.

@@ -68,7 +68,9 @@
<td class="nowrap">{{ loop.index }}</td>
<td class="nowrap">{{ '%0.3f'|format(command.durationMicros / 1000) }} ms</td>
<td class="nowrap">{{ command.database }}</td>
<td>{{ command.command }}</td>
<td>
<pre>{{ command.command|json_encode(constant('JSON_PRETTY_PRINT')) }}</pre>
Copy link
Member

Choose a reason for hiding this comment

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

I think we should show the non-pretty-print one first and allow to expand it for the pretty print one. You can use data-toggle-selector attributes to achieve it. See https://github.com/doctrine/DoctrineBundle/blob/2.4.x/Resources/views/Collector/db.html.twig

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done by using existing queries-table and sql-runnable CSS classes.

@Jean-Beru
Copy link
Contributor Author

The CI failed :

==> Setup Extensions
✗ mongodb-1.10.12 Could not install mongodb-1.10.12 on PHP 7.2.34
Error: The process '/usr/bin/bash' failed with exit code 1

Is it due to ext-mongodb in composer.json ? 🤔

@alcaeus
Copy link
Member

alcaeus commented Jul 29, 2021

I'll have to investigate what's going on here: 1.10.12 does not exist, and the build specifically calls for installing 1.5.0. For some reason, the version matches what we had above for pecl, so I'm inclined to think there's a separate issue going on. I'll take a look.

@alcaeus alcaeus added this to the 4.4.0 milestone Aug 11, 2021
@alcaeus alcaeus changed the base branch from 4.3.x to 4.4.x August 11, 2021 06:57
@alcaeus alcaeus self-assigned this Aug 11, 2021
@alcaeus alcaeus force-pushed the feature/improve-collector-view branch from bfb536b to 9bec393 Compare August 11, 2021 07:10
@alcaeus
Copy link
Member

alcaeus commented Aug 11, 2021

I've updated the target branch to 4.4.x and rebased, which of course adds psalm errors. @franmomu would you be able to add the array shapes to this so we can wrap it up? Thanks!

@franmomu
Copy link
Contributor

There you go!

@alcaeus alcaeus merged commit cfa2ec4 into doctrine:4.4.x Aug 11, 2021
@alcaeus
Copy link
Member

alcaeus commented Aug 11, 2021

You're a legend, @franmomu! Thanks @Jean-Beru and @IonBazan for getting this one done! 🎉

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.

Show query time in profiler
5 participants