PHP is currently one of the most popular programming languages, thanks to the richness of its functions, ease of use, and simplicity. Many web applications have been created in PHP, including popular content management systems like WordPress and e-commerce platforms like Magento. Besides being the most popular web server back end, PHP is also commonly used for developing microservices, shell applications, high-scale back ends, and for scheduling automated tasks.
Dynatrace has long provided automatic code-level performance monitoring for PHP applications with OneAgent. To further expand this, we’ve been working hard over recent months to deliver the Early Adopter release of Dynatrace AI-powered PHP CLI monitoring, as of OneAgent version 1.181. (PHP NG monitoring, a prerequisite, has been available since OneAgent version 1.179.) Here’s what you can do with Dynatrace PHP CLI monitoring:
- Analyze the performance of your PHP CLI application.
- Automatically locate bottlenecks in your code.
- Understand why communication with the database takes a long time.
- Find out whether the application manages memory properly.
Full code-level visibility into your PHP CLI application
We’re happy to announce that now you can enable deep monitoring for your PHP CLI applications. This provides you with database visibility, threading support, outgoing call monitoring, and more. Here’s what you get:
- Thread safe and non-thread safe PHP CLI support for all Dynatrace supported PHP versions
- All existing OneAgent PHP features and CLI-only features:
- pthreads support for PHP CLI (thread safe)
- Method hotspots using ambient sampling
- Support for request attributes
- Deep monitoring after enabling custom service detection
Full PHP insights into database connections and more
When you enable Custom service detection, you get deep monitoring, including pthreads monitoring and full PHP insights into database connections and external calls.
To learn more about custom service detection for PHP, see our blog post Introducing custom service detection for PHP.
See whether your application manages memory properly
With the garbage collection and OPcache metrics, you now have visibility into how your application manages memory. You also get detailed process metrics, including CPU usage, memory usage, worker processes, and I/O information out of the box.
Easily find the most CPU-consuming methods with method hotspots
You can easily find and fix the most CPU-consuming methods within your PHP code. The image below shows method hotspots for a service:
How to get started
Before getting started, make sure you have Dynatrace OneAgent version 1.181+ installed on all monitored hosts.
- Go to Settings > Monitoring > Monitored technologies > PHP > Enable PHP NG monitoring on each host.
- Go to Settings > Processes and containers > Process group monitoring > Process monitoring rules and define custom process monitoring rules for PHP CLI.
- You can build your rules based on conditions such as:
- EXE name
- EXE path
- PHP script
- PHP working directory
To learn more about process-monitoring rules, see our blog post Automated and fine-grained control of monitoring at scale.
- Restart your PHP application.
Known limitations
- Injection of OneAgent causes slight overhead upon process startup, so it should not be enabled for short-lived processes. Note that we’re currently working on remediating this issue.
- Forking inside PHP CLI processes is not supported (pcntl_fork and other execution functions)—in this scenario, OneAgent becomes inactive.
- Instrumentation of PHP CLI processes with code specified as a command-line argument is not supported.
- Instrumentation of pthreads is supported from PHP 7.2 to PHP 7.3. Earlier PHP releases are not fully thread safe and should not be used with pthreads.
What’s next and feedback
We’re currently working on parallel support for PHP CLI version 7.2+. Also, as mentioned above, we’re remediating the overhead caused upon process startup. As always, we want to hear from you regarding what’s working or not working for you. Please share your feedback with us at Dynatrace answers.
Looking for answers?
Start a new discussion or ask for help in our Q&A forum.
Go to forum