Blackfire CLI client offers the possibility to output the profile data in JSON, using the --json option:

blackfire curl --json https://localhost/foo/bar

When using this option, both STDOUT and STDERR are leveraged:

  • JSON formatted output is displayed on STDOUT

  • Regular output (e.g. progress, summary, profile URL)

Issue with Docker Compose

Docker Compose has a long-standing known issue with STDOUT and STDERR. Long story short, it mixes both outputs up, which leads to JSON parse errors, since the output then contains regular unformatted text along with JSON formatted data.

For example, using jq on the output can lead to the following error:

$ docker-compose exec bf blackfire curl --json https://localhost/foo/bar | jq

parse error: Invalid numeric literal

This is due to the Docker pseudo TTY which is allocated by default.


To workaround this issue, you need to disable the pseudo TTY with docker-compose -T option:

$ docker-compose exec -T bf blackfire curl --json https://localhost/foo/bar

Did this answer your question?