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

Blackfire CLI profiling #187

Closed
Vinai opened this issue Jul 10, 2020 · 5 comments · Fixed by #188
Closed

Blackfire CLI profiling #187

Vinai opened this issue Jul 10, 2020 · 5 comments · Fixed by #188
Labels
enhancement New feature or request
Milestone

Comments

@Vinai
Copy link
Contributor

Vinai commented Jul 10, 2020

Profiling Magento 2 with the blackfire browser extension works well.
But what is the right way to run the blackfire command line tool to profile, for example, bin/magento commands?

@navarr
Copy link
Member

navarr commented Jul 10, 2020

Bad news, there is not yet a way to do so!

I've just reviewed the Blackfire documentation, though, and will be contributing it soon.

Once it's contributed, the way to do so would be to run:

warden env exec php-blackfire /bin/bash if you wanted a shell that supports the blackfire command.

@navarr
Copy link
Member

navarr commented Jul 10, 2020

As a workaround while you wait,

You can add a .warden/warden-env.yml with the content:

version: "3.5"
services:
  php-blackfire:
    environment:
      - BLACKFIRE_CLIENT_ID=${BLACKFIRE_CLIENT_ID}
      - BLACKFIRE_CLIENT_TOKEN=${BLACKFIRE_CLIENT_TOKEN}

Then run a warden env up -d to bring your environment back up with the new configuration, and run warden env exec php-blackfire /bin/bash, from there, a sudo su - and run:

mkdir -p /tmp/blackfire \
    && curl -A "Docker" -L https://blackfire.io/api/v1/releases/client/linux_static/amd64 | tar zxp -C /tmp/blackfire \
    && mv /tmp/blackfire/blackfire /usr/bin/blackfire \
    && rm -rf /tmp/blackfire

This will install the blackfire client, and then once you drop out of sudo you should be able to run blackfire run bin/magento

@Vinai
Copy link
Contributor Author

Vinai commented Jul 10, 2020

Thank you!

@navarr
Copy link
Member

navarr commented Jul 10, 2020

@Vinai: Full disclosure, I did not test the workaround. But in theory it does the same thing as the changes I've submitted in #188

I did test installing blackfire client like that and running it, but I was testing based on the warden-env.yml being part of the primary yaml.

@davidalger davidalger added the enhancement New feature or request label Jul 10, 2020
@davidalger davidalger added this to the Warden 0.7.0 milestone Jul 10, 2020
@davidalger
Copy link
Collaborator

davidalger commented Jul 10, 2020

Thanks for implementing this @navarr. I've merged the PR into develop mainline and plan to include it in the next minor release.

@davidalger davidalger linked a pull request Jul 10, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants