Skip to content

feat(symfony): add an Elastically panel to the Symfony profiler - #237

Open
lyrixx wants to merge 1 commit into
masterfrom
issue-38
Open

lyrixx wants to merge 1 commit into
masterfrom
issue-38

Conversation

@lyrixx

@lyrixx lyrixx commented Sep 26, 2026 •

Copy link
Copy Markdown
Member

Fix #38

When the Symfony profiler is enabled, the bundle now adds an "Elastically" panel and a web debug toolbar item.

For each connection, the panel lists the requests sent to Elasticsearch with:

  • the duration and the status code (a HEAD answered by a 404, like Index::exists(), is not counted as an error);
  • the request body and the response, dumped with the VarDumper (bulk NDJSON bodies are decoded line by line);
  • a "Copy as cURL" button (credentials are stripped) and a "Copy for Kibana Dev Tools" button;
  • a warning when the exact same request (method, URL, body) is sent more than once.

The stopwatch is also fed, so the requests show up in the Performance panel.

Screenshots:

The web debug toolbar:

Elastically item of the web debug toolbar

The panel, with a duplicated request and an error:

Elastically panel of the profiler

The request body and the response of a search:

Request body and response of a search request

How it works:

  • TraceableClient extends Client and records each request in sendRequest(), which has the same signature with Elastica 8 and 9.
  • DataCollectorPass does nothing unless the profiler service exists. Otherwise it swaps the class of every connection client to TraceableClient and registers the ElasticallyDataCollector. Nothing to configure, and no change when the profiler is disabled (prod).

Not done here, but could come later: "explain" / "profile" / "replay" buttons.

symfony/twig-bundle, symfony/web-profiler-bundle and symfony/css-selector are added to require-dev for the functional test, which renders the panel.

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.

[Feature] add DataCollector for elastically

1 participant