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
Add Blackfire agent and full support #2448
Conversation
Traditionally people have done this with an additional service, as shown in https://github.com/drud/ddev-contrib/tree/master/docker-compose-services/blackfire - it seems to have worked OK for some time. |
Yes, I noticed the additional service. However it be cumbersome to use the CLI within the agent container when one want to profile CLI commands, or use it for other purposes (e.g. bootstraping tests, triggering build webhooks...) This is why I am proposing this change. |
I guess I was assuming that most people would take the first option there and install the client on their host machine. I always use the Chrome extension when testing. I do wish the CLI were available via separate download. Also: If we wanted this to be added to the base image to be used by DDEV-Live (in the future), we'd want this PR in drud/ddev-images rather than here. I added a commit to point to a newly-pushed docker image, and remove the init.d stuff, since the container doesn't run systemd or any init system (processes start with supervisord) I note that this adds about 11MB to the compressed image size, which is certainly more than I wish it did. https://hub.docker.com/repository/docker/drud/ddev-webserver/tags |
Thanks @rfay ! Question: How are all these pieces of software been updated? |
I can definitely move this PR to https://github.com/drud/ddev-images/ ! |
I think we should consider moving this as is to drud/ddev-images, depending on the strategy being used in DDEV-Live, I'll check on that today. Maybe we'll just end up adding a command to start the agent on DDEV-Local and have the whole thing built in. |
That's my guess too.
That will work for DDEV-Local, but for DDEV-Live you'll most likely want to have a separate container. |
Interesting,
We'll have to know more about that, and it could be a blocker for this approach. I'm not sure the Blackfire package would know how to determine the default version. And of course, it's not actually determined until start time. Could you take another look at how that works before we move forward please? |
OK I just checked and we're actually fine 😃 . Our installer script can find its way to every version of PHP installed. Regarding the agent, we could install it into the app container, but how DDEV-Live work with these containers? There should be only one agent per app. |
So @lolautruche it seems that the goal in DDEV-Live is to put the agent in a separate container (as is done in the ddev-contrib recipe) and so it doesn't make any sense for us to fiddle with ddev-images at this point. So that sounds to me like your objective will be met by getting just the blackfire CLI into ddev-webserver, and perhaps as just the CLI, not the full package.
So a new version of ddev-webserver is tagged for each major release and sometimes for minor. But they don't get updated unless people update DDEV-Local. |
@josefkarasek bringing you into this issue. @lolautruche @josefkarasek is working on the DDEV-Live Blackfire integration. |
Oh, I forgot to mention: The blackfire CLI is already in the blackfire container, of course, so one can use it with just |
OK. I can update the Dockerfile to only install the CLI. However it won't be easy to update it (there is no selfupdate command).
Is it possible for users to update their packages? Because we roll out updates of the probe, agent and CLI tool quite often.
Yes, I noticed the ddev-contrib recipe. However, while the CLI tool is usable from there to do |
It's unusual for users to update packages; DDEV-Local versions come out every 2-3 months, so that's usually the path for most people to get new packages. They could update by putting Also, we support custom Dockerfile add-ons for things like this, and post-start hooks. But my bet is that people wouldn't be updating that often. If they do need an update, there are easy techniques. I note that the blackfire CLI is about 13MB uncompressed, as is the agent. So perhaps we're winning half the disk space back with this approach. |
One note though, as mentioned above, any user can already add |
Right, I wanted to improve the developer experience as the |
It may be fine to just add a little doc to the ddev-contrib recipe. OTOH, we certainly want people to enjoy the ddev/blackfire experience as much as possible, and they have in fact enjoyed it (blackfire is awesome) |
There are already a few lines about getting the CLI client by adding |
I sure appreciate your initiative on this @lolautruche - I'm thinking the best path forward is just to put the package into ddev-images, but haven't completely decided. Also, if we decide to do that, we could possibly add a command to ddev to enable the agent when needed, and simplify everything for blackfire users. |
That would really rock! Let me know about your decision, I can surely adapt this PR in order to only install the CLI. |
Oh, and here is the official documentation on Blackfire website: https://blackfire.io/docs/integrations/paas/ddev |
@lolautruche I think we should try to get this into v1.17, with the agent and the probe in the web image. So what we'd do is
What do you think? |
I think it's great @rfay! |
a41b211
to
f09173a
Compare
I rebased this and made a couple of changes:
What I think I'll do is wait until Environment variables in config.yaml #2742 goes in, which would make it super easy to add the environment variables. Then we may just be able to use the agent at will, we'll see. One question @lolautruche: Where are you on PHP8.0 support? I do see it whining during the build about PHP8.0 config files. |
Awesome!
👍
PHP 8.0 is officially supported, with a dependency on curl extension (for now). What is the problem with the build exactly? I couldn't find out. |
@leymannx the PHP8.0 thing I see is in the container build:
This is in https://github.com/drud/ddev/pull/2448/checks?check_run_id=1681814057 And of course with php8.0,
It looks like there may be an improvement needing to be made in the blackfire-php debian package to make sure the file gets created? (It does fine in php7.4 and below) |
@rfay We indeed have an issue with debian packages. A fix has been implemented and should be rolled out shortly |
I should mention that since ddev doesn't use systemd or init inside the containers, you don't run the agent by running /etc/init.d/blackfire or whatever, just run blackfire-agent, and it doesn't need extra privileges, although sudo is available. |
@rfay The logs are the agent's. It would be useful to get the ones from the agent and the probe. Furthermore, the logs mentions an outdated version of blackfire-agent: v1.45.1 |
I'll check it out using the Linux artifact. I just need to run |
blackfire-agent 1.45.1 is the one currently being served up from your repository:
I'll be out for the rest of your workday, but thanks so much for taking a look. Yes, just run |
Sorry I mixed up with the probe version |
So, I did some tests and there are few issues:
In any case, as I already stated before, it is generally not a good idea to have |
Nice work - you pointed out the problem. Although the script was doing the phpenmod, I forgot to kill -HUP the php-fpm. I must have been remembering to manually do that earlier and then it fell out of my mind when I started scripting the process. Works perfectly now. I know you're reluctant to have this in the same container, but since it's an on/off that people can easily use, I'm thinking it will make blackfire super accessible to people, with almost no config required. It's not "running in the background" as much as "being turned on when needed". |
|
Blackfire CLI makes it possible to profile CLI commands. It needs to be configured with credentials with env vars as documented on Blackfire website: https://blackfire.io/docs/configuration/cli
bc5b962
to
a582349
Compare
New artifacts are at https://app.circleci.com/pipelines/github/drud/ddev/3539/workflows/361fd4d3-474c-4795-a82d-a5753ed708ec/jobs/30799/artifacts - would love to have you take it for a spin. I failed to mention that the Again, the proposed docs are at https://github.com/drud/ddev/blob/a58234910204d097a6c2babef990bb9fc284eb04/docs/users/blackfire-profiling.md |
docs/users/blackfire-profiling.md
Outdated
### Basic Blackfire Usage | ||
|
||
1. Create an account on [blackfire.io](https://blackfire.io) | ||
2. Get the Server ID and the Server Token from your Account->Credentials on blackfire.io |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Server Credentials may come from an environment the user is being part of.
Client credentials should be retrieved as well (Account/Credentials)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don' t really understand "may come from an environment the user is being part of" - but we can link to docs if you can point me to it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A Blackfire user may be part of an organization, and the latter may have one or several collaborative environments.
The easiest way is to use the personal credentials (the user inherit most of the org permissions), but doing so prevents the profiles to be shared within the team working in an environment.
See the documentation here: https://blackfire.io/docs/up-and-running/configuration/agent#configuring-the-agent-via-environment-variables. A user may have a dropdown menu like this:
docs/users/blackfire-profiling.md
Outdated
|
||
1. Create an account on [blackfire.io](https://blackfire.io) | ||
2. Get the Server ID and the Server Token from your Account->Credentials on blackfire.io | ||
3. Configure ddev with the credentials, `ddev config global --web-environment="BLACKFIRE_SERVER_ID=<id>,BLACKFIRE_SERVER_TOKEN=<token>"`. It's easiest to do this globally, but you can do the same thing with project-level `ddev config`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that this command doesn't append but replaces the env vars to the global web_environment
setting.
Is there a way to append variables instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The environment variable feature was just added in the previous PR (prompted by the need here, you used to have to do a docker-compose override), so I'm sure it will have some maturing to do. Most people just edit the appropriate configuration, the project .ddev/config.yaml or the global ~/.ddev/global_config.yaml - so that's the easiest way to just "edit" a set of env vars.
You're right, I find it very accessible myself and I'm happy with it 😃 . |
Co-authored-by: Jérôme Vieilledent <lolautruche@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review and careful thought. I've made a number of updates to the script and to the docs.
docs/users/blackfire-profiling.md
Outdated
### Basic Blackfire Usage | ||
|
||
1. Create an account on [blackfire.io](https://blackfire.io) | ||
2. Get the Server ID and the Server Token from your Account->Credentials on blackfire.io |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don' t really understand "may come from an environment the user is being part of" - but we can link to docs if you can point me to it.
docs/users/blackfire-profiling.md
Outdated
|
||
1. Create an account on [blackfire.io](https://blackfire.io) | ||
2. Get the Server ID and the Server Token from your Account->Credentials on blackfire.io | ||
3. Configure ddev with the credentials, `ddev config global --web-environment="BLACKFIRE_SERVER_ID=<id>,BLACKFIRE_SERVER_TOKEN=<token>"`. It's easiest to do this globally, but you can do the same thing with project-level `ddev config`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The environment variable feature was just added in the previous PR (prompted by the need here, you used to have to do a docker-compose override), so I'm sure it will have some maturing to do. Most people just edit the appropriate configuration, the project .ddev/config.yaml or the global ~/.ddev/global_config.yaml - so that's the easiest way to just "edit" a set of env vars.
Thanks for all the work on this! Let's get it into a prerelease and see if we can get some feedback from people. |
Awesome! |
The Problem/Issue/Bug:
Blackfire CLI makes it possible to profile CLI commands.
It needs to be configured with credentials with env vars as documented
on Blackfire website: https://blackfire.io/docs/configuration/cli
How this PR Solves The Problem:
It installs
blackfire-agent
package, which bundlesblackfire
CLI command.It is much easier for the developer to have access to the
blackfire
command directly from the main container.The agent is however disabled (prevented to run on startup), to keep using the dedicated image.
Manual Testing Instructions:
Automated Testing Overview:
Related Issue Link(s):
Release/Deployment notes: