How to profile a PHP shell script app or worker using Blackfire -
i noticed when have endless worker cannot profile php shell scripts. because when it's killed doesn't send probe.
what changes shall do?
when trying profile worker running endless loop. in case have manually edit code either remove endless loop or instrument code manually call close() method of probe (https://blackfire.io/doc/manual-instrumentation).
that's because data sent agent when close() method called (it called automatically @ end of program unless killed it).
you can manually instrument code using blackfireprobe class comes bundled blackfire's probe:
// probe main instance $probe = blackfireprobe::getmaininstance(); // start profiling code $probe->enable(); // calling close() instead of disable() stops profiling , forces collected data sent blackfire: // stop profiling // send result blackfire $probe->close();
as auto-instrumentation, profiling active when code run through companion or blackfire cli utility. if not, calls converted noops.
Comments
Post a Comment