Skip to content

Add the Symfony Profiler

Fridtjof requested to merge fridtjof-symfony-profiler into master

What does this MR do?

This MR adds the Symfony Profiler (and Web Debug Toolbar) to the project.

Todo items:

  • Symfony gets the URL to load the web debug toolbar from wrong in dev, because requests to it are proxied through the (client) webpack dev server. Setting changeOrigin to false in client/serve.config.js fixes this, without any obvious problems.
  • Some links on the profiler page are "broken" because something in Symfony assumes the base URL is web:8080 - I haven't figured out how to override this with localhost:18080 yet.
  • Any requests triggered (indirectly) by any JS in head.scripts (see line 173 in templates/layouts/base.twig) will not show up in the toolbar, because its load script is injected at the very end of the body, after any HTML we put in. That means that it will execute only after many requests already went through. They are still visible in the Profiler itself, though.

See https://symfony.com/doc/5.4/profiler.html#timing-the-execution-of-the-application on how to add information to the profiler in a controller.

What does it look like?

grafik.png

grafik.png

grafik.png

grafik.png

grafik.png

grafik.png

How confident are you it won't break things if deployed?

pretty confident, anything that would directly affect prod is gated behind $ENV === 'dev', or is only enabled for the dev environment anyway.

Links to related issues

https://yunity.slack.com/archives/C1T1ZM9A4/p1581781459456400

How to test

Steps a reviewer can take to verify that this MR does what it says it does e.g.

  1. Checkout branch locally
  2. ./scripts/composer install

Then, either:

For the REST API:

  1. set off a request to any REST API (e.g. /api/baskets/)
  2. Check the response's header for a header called "X-Debug-Token"
  3. Append its value to this path: http://localhost:18080/_profiler/
  4. The Symfony profiler should show up, giving you various insights into the request

For the website:

  1. Go to any website
  2. click on the status code on the left side of the new toolbar
  3. The Symfony profiler will show up, giving you various insights into the request

Or alternatively, you can check http://localhost:18080/_profiler/ to see all recently profiled requests.

Checklist

  • no test, this is just a new dev toy
  • no unrelated changes
  • asked someone for a code review
  • added an entry to CHANGELOG.md (description, merge request link, username(s))
Edited by Fridtjof

Merge request reports