Reputation: 1386
I have rabbitmq consumers written in php with symfony2-framework, and I'm trying to see the inner workings and issues of the system with xhprof. Problem is that it's not saving anything into the mongodb. Mongo is totally empty.
I've tried to set the auto_prepend_file(which adds the necessary header-file) in php.ini, the applications .htaccess -file, and the apaches virtual hosts.
I set the profiler to profile every request and it profiles everything else just fine, eeexcept the rabbitmq-consumers running in the background. But why not?
For instance, I called phpinfo.php -file and it profiled it perfectly, but not the consumers, nope.
Upvotes: 1
Views: 272
Reputation: 1752
Xhprof does not forcibly save the profile data when the script exits. But when you instruct him to do so. Lot of setups includes something like from https://github.com/patrickallaert/xhprof#profile-your-page, using register_shutdown_function()
, which gets executed at the end of a script.
But it is up to you to put xhprof_enable()
/ xhprof_disable()
around the code that you want to profile. It is also perfectly valid in a loop, example:
<?php
while (true) {
// Fetch a message from the queue
// Start profiling
xhprof_enable();
// [treatment of your message]
// End profiling and dump the result
file_put_contents("/tmp/" . uniqid() . ".your_app.xhprof", serialize(xhprof_disable()));
}
Upvotes: 1
Reputation: 1386
Xhprof profiles the data when the script exists which is kinda never for the rabbitmq consumers, since they are processes running in the background.
So: One solution would be to add the appropriate begin and exit -codes from the header-file in to the scripts that are running, but this is way too much trouble for me.
I ended up using PHP's own XDebug with visualizing tool: Webgrind.
Upvotes: -1