OCI8 2.0 introduced static DTrace probes that can be used on
operating systems that support DTrace.
See DTrace Dynamic Tracing
for an overview of PHP and DTrace.
Installing OCI8 with DTrace Support
To enable DTrace support in PHP OCI8, build OCI8 as a shared
extension after setting PHP_DTRACE.
$ export PHP_DTRACE=yes
$ pecl install oci8
Edit php.ini,
set extension_dir to the
directory with the created oci8.so and also
enable the extension by adding:
extension=oci8.so
If you install PHP OCI8 from PECL using phpize and
configure (instead
of pecl), you will still need to set
PHP_DTRACE=yes. This is because
the --enable-dtrace option will be ignored by the
limited configure script of a PECL bundle.
This script uses the -Z option to
dtrace, allowing it to be run when there is no
PHP process executing. If this option were omitted the script
would immediately terminate when no PHP executable was running
because it knows none of the probes to be monitored are in
existence.
On multi-CPU machines the probe ordering might not appear to be
sequential. This depends on which CPU was processing the probes,
and how threads migrate across CPUs. Displaying probe time stamps
helps reduce confusion.
The script traces all user-level PHP OCI8 static probe points
throughout the duration of a running PHP script. Run the D script:
# ./user_oci8_probes.d
Run a PHP script or application. The monitoring D script will
output each probe's arguments as it fires. For example, a simple
PHP script that queries a table might produce the following trace
output: