Enabling and configuring PHP tracing
By default, PHP tracing is enabled in the agent configuration file. When PHP tracing is enabled, the PHP sensor automatically installs the PHP Tracer (also referred to as the Instana PHP Tracing extension) in your PHP runtime.
Requirements
The PHP sensor enables tracing only if the detected PHP runtime has the JSON extension support. If any of the following extensions are detected in a PHP runtime, the PHP Tracer installation is disabled automatically:
- SourceGuardian
- New Relic
- Dynatrace
- Datadog
If the ionCube Loader extension is detected in a PHP runtime, the PHP Tracer is installed with PHP userland tracing disabled.
PHP tracing process
When PHP tracing is enabled in the agent configuration file, the process of installing and configuring PHP Tracing extension is handled automatically by the PHP sensor as outlined in the following steps:
-
The PHP sensor downloads the PHP Tracing extension and enables it in the PHP runtime INI configuration as follows:
- If the PHP runtime is configured with a separate directory for additional INI files, the PHP sensor places a
zzz-instana.inifile containing the PHP Tracing extension's INI settings in this directory. - Otherwise, the PHP sensor configures PHP Tracer by appending the INI settings to the main
php.inifile.
Do not modify
zzz-instana.inibecause the PHP sensor overwrites it during every installation based on the configurations in the Instana agentconfiguration.yamlfile. - If the PHP runtime is configured with a separate directory for additional INI files, the PHP sensor places a
-
The PHP sensor then attempts to gracefully restart the PHP environment to load the PHP Tracing extension into memory.
-
If the PHP runtime is successfully restarted, the PHP Tracing extension starts collecting traces in the PHP runtime.
-
If the automatic restart doesn't work due to the SAPI type of the PHP runtime, you need to manually restart PHP to load the PHP Tracing extension into memory. For more information on automating the PHP runtime restart, see Automatic restarts.
-
The PHP sensor generates reasonable defaults for PHP Tracing extension's INI settings. However, you can adjust these settings to accommodate for highly specific needs. For more information, see Advanced customization.
If you encounter issues with automatic installation of the PHP Tracing extension, you can also manually install it. For more information, see Manually installing PHP Tracing extension.
Advanced customization
The PHP sensor frequently overwrites zzz-instana.ini, so do not change this INI file. Instead, you can add your own custom INI file that overrides the default Instana INI settings in zzz-instana.ini. PHP loads the INI files in alphanumeric order, with the last occuring instance of a setting being the effective value. To make sure the INI settings in your custom INI file override the INI settings in zzz-instana.ini, name your custom INI file to zzzzz-instana-extras.ini (notice the prefix zzzzz-) so that it loads after zzz-instana.ini. In containerized scenarios, your custom INI file can be mounted dynamically or made part of the image.
The following settings are available for all versions of PHP:
-
instana.batch_threshold_us: The length and distance threshold in which batching of spans happens. The default value is 10000. -
instana.backtrace_limit: Controls the depth of recorded call stacks. The default or capped value is 25 entries. -
instana.disabled_instrumentation(deprecated): Specifies a bitmask of instrumentations to disable. The default value is 0 (none). For more details, refer to the Disabling instrumentation section. This INI setting is deprecated and replaced by the span disabling feature, which provides better instrumentation disabling configurability. -
instana.disable_userland_tracing: Disables all tracing for non-native PHP extensions and PHP userland code like frameworks. The default value is 0 (off). -
instana.enable_cli: Enable or disable tracing for the CLI SAPI. 1 = on. 0 = off. The default value is 0 (off). -
instana.log_level: The level to log: 0 = off, 1 = ERROR, 2 = WARN, 3 = INFO, and 4 = DEBUG. The default value is 0 (off). -
instana.segfault_error_log: Capture or avoid a backtrace to PHP's error log-on segfaults. The default value is 0 (off). -
instana.span_chunk_size: The number of spans to keep in PHP's memory before they are sent to the agent. This number directly affects batching. For example, chunks of one effectively disable batching.
The following settings are exclusive to PHP 5:
-
instana.socket: The address of the TCP socket of the Instana PHP sensor. The socket address is determined during installation and defaults to tcp://127.0.0.1:16816.
The following settings are exclusive to PHP 7.0 and later:
-
instana.buffer_hard_limit: The maximum number of spans to be kept in the buffer if the agent becomes unresponsive. Spans starting from the oldest are dropped until the buffer is contained within this limit. The default value is 1000. -
instana.buffer_maximum_delay_ms: The maximum interval between subsequent clearance of a span buffer. The default value is 1000 ms. -
instana.buffer_soft_limit: The maximum number of spans to be buffered before a span buffer is cleared. The default value is 500.
The following settings are exclusive to PHP 8.1 and later:
-
instana.span_filter_config_file: Specifies the absolute path of the YAML file that contains the configuration to disable traces. The PHP sensor updates this setting to enable span disabling through the agentconfiguration.yamlfile. The default value is<System_Temp>/instana-php/instana_span_filter_config.yaml. For more details about this setting, refer to the Additional configuration section.
The following table is a complete list of environment variables for configuring the PHP extension:
| Environment variable | Default value |
|---|---|
INSTANA_AGENT_HOST |
127.0.0.1 |
INSTANA_AGENT_PORT |
42699 |
INSTANA_SERVICE_NAME |
EMPTY |
INSTANA_DEBUG |
OFF |
INSTANA_STACK_TRACE_LENGTH |
25 |
INSTANA_EXTRA_HTTP_HEADERS |
NONE |
INSTANA_SECRETS |
password, key, secret |
INSTANA_LOG_LEVEL |
NONE |
The presence of these environment variables will take precedence over configurations in zzz-instana.ini. For more information, see environment variables.
If you need help with these settings, contact IBM Support.
Capturing custom HTTP headers
PHP Tracer can capture custom HTTP headers in entry and exit spans. To capture these headers, specify the list of headers in any one of the following configurations:
-
PHP INI setting:
instana.extra_http_headers=HEADER1,HEADER2 -
Environment variable configuration:
INSTANA_EXTRA_HTTP_HEADERS=HEADER1;HEADER2
Alternatively, you can capture the HTTP headers of every tracked request or response by setting the headers list in the agent configuration.yaml file. For more information, see Capturing custom HTTP headers
The PHP Tracer preserves spaces in both header keys and values.
Disabling spans
The PHP Tracer supports disabling traces or spans for specific span type (frameworks, libraries, and instrumentations) or entire groups of libraries (span category). With this span disabling feature, you can customize the tracing according to the needs of your application, resulting in reduced network costs by reporting only the traces that are essential to your application.
Use one of the following methods to provide the configuration to disable tracing:
Additional steps are required for configuring span disabling in Apache and IIS servers. For details, see Additional configuration. For details on how Instana prioritizes span disabling, see Configuration precedence for disabling spans.
Configuring through environment variables
To disable tracing through environment variable, set the environment variable INSTANA_CONFIG_PATH to the absolute path of the YAML file with your configuration.
For example, to disable tracing for all databases calls (except MongoDB) and all logging frameworks, copy the following code into a separate YAML file:
tracing:
disable:
- databases: true
- mongodb: false
- logging: true
Set the environment variable INSTANA_CONFIG_PATH to the absolute path of the YAML file to which the content is placed as follows:
INSTANA_CONFIG_PATH=<your YAML file>
Configuring through Instana agent configuration
To disable tracing through Instana agent configuration, disable traces under the com.instana.tracing.disable section in the agent configuration.yaml file.
To disable tracing for all database calls (except Redis) and all logging frameworks, update the com.instana.tracing section in your agent configuration.yaml file as shown in the following example:
com.instana.tracing:
disable:
- databases: true
- redis: false
- logging: true
For more information about customizing the configuration, see Disabling tracing.
Disabling tracing for a category disables the span generation for all the libraries under that category. See the following list of categories supported by PHP Tracer:
- databases
- frameworks
- messaging
- protocols
- logging
- templating
- Others (No category key is available for others)
Configuration precedence for disabling spans
Span disabling rules are applied in the following order of precedence, listed from highest to lowest:
- Span disabling rules from the configuration file that is passed through the
INSTANA_CONFIG_PATHenvironment variable. - Span disabling configured in the
instana.disabled_instrumentationini setting. - Span disabling rules from the agent
configuration.yamlfile.
This precedence is enforced at the feature level. If a PHP runtime detects multiple configurations in a feature, it applies the span disabling rules from the configuration with the highest precedence. For example, if a PHP runtime has the following span disabling rules set through INSTANA_CONFIG_PATH environment variable:
com.instana.tracing:
disable:
- logging: true
- databases: true
- redis: false
And the same runtime has the following ini setting:
instana.disabled_instrumentation=24 ; disables redis (16) and curl (8) instrumentations
With this example configuration, the PHP Tracer works as follows:
- Tracing for all logging libraries is disabled.
- Tracing for all databases is disabled except for Redis.
The instana.disabled_instrumentation ini setting is ignored as the INSTANA_CONFIG_PATH environment variable takes precedence. Therefore, all instrumentations that are not disabled through the configuration file specified by the INSTANA_CONFIG_PATH environment variable are enabled.
If span disabling rules are set through both the INSTANA_CONFIG_PATH environment variable and the agent configuration.yaml file, then the rules from the configuration.yaml file are ignored.
Additional configuration
The PHP sensor detects any changes in the agent configuration.yaml file and makes a copy of the section com.instana.tracing.disable into a separate file located at <System Temp>/instana-php/instana_span_filer_config.yaml. The generated file's absolute path is set to the instana.span_filter_config_file ini setting so that PHP Tracer can detect and apply any subsequent changes to the configuration.yaml file without any restarts to the PHP runtime. Therefore, the PHP runtime needs to have read access to the system's temp folder, if you are configuring span disabling rules through agent configuration.yaml file.
The following subsections provide the additional steps that are required in some environments for the PHP runtime to have sufficient access to the system's temp folder.
Apache server
Apache server on Linux-based OS might be configured to have an isolated temp folder as opposed to using the system's temp folder. For the PHP Tracer to access the configuration file located in the system's temp folder, make sure that the PrivateTmp is set to false by performing the following steps:
-
Edit the
Systemd unitfile by running the following command:sudo systemctl edit apache2.service -
Add or update the
PrivateTmpproperty in the Service section:[Service] PrivateTmp=false -
Restart the Apache server to apply the changes.
To avoid updating the PrivateTmp, you can configure the span disabling rules through environment variable.
IIS server
IIS worker processes sometimes lack access to the Windows temp folder. This insufficient access to the temp folder is due to the application pool identity that is used to run the worker processes lacking sufficient read or write permissions to the temp folder. To resolve this access issue, perform the following steps:
-
Confirm the identity of your application pool by running the following command in your PowerShell terminal:
& $env:windir\system32\inetsrv\appcmd.exe list apppool <your AppPool> /text:processModel.identityType -
If the identity is not
ApplicationPoolIdentity, run the following command to update the identity:& $env:windir\system32\inetsrv\appcmd.exe set AppPool <your AppPool> -processModel.identityType:ApplicationPoolIdentity -
Restart your application pool to apply the changes:
& $env:windir\system32\inetsrv\appcmd.exe recycle apppool <your AppPool>IIS server detects the application pool running with the identity
ApplicationPoolIdentity, and creates a virtual user with the name of your application pool. -
To give the PHP runtime, that is, IIS worker processes read access to the
<SYSTEM_TEMP>/instana-phpdirectory, use the following command:icacls "<SYSTEM_TEMP>\instana-php" /grant "IIS APPPOOL\<your AppPool>:(OI)(CI)R" /T /C
Disabling instrumentation
To disable instrumentation for a specific library or a set of libraries from the PHP ini settings, use the instana.disabled_instrumentation setting. It takes the bitmask value of the libraries for which you want the tracing to be disabled. To get the bitmask values of the libraries, refer to the Instrumentation flag column located in the Instrumented libraries and frameworks section.
To disable instrumentation for multiple libraries, add its respective Instrumentation flag values. For example, to disable tracing for MongoDB calls (with instrumentation flag: 32) and Redis data store calls (with instrumentation flag: 16), add the following line in your ini settings file:
instana.disabled_instrumentation=48 ; 32 + 16 = 48
Use the Disabling spans feature instead of the instana.disabled_instrumentation setting for better control over generating spans in your PHP Tracer.
Automatic restarts
Since PHP Tracer is a PHP extension that is loaded into the PHP runtime, enabling and disabling PHP tracing or changing the installed PHP Tracing extension version requires a restart of the PHP runtime for the changes to take effect.
The PHP sensor is capable of automatically and gracefully restarting Apache and PHP-FPM runtimes. But manual restart is required for the following PHP runtime scenarios:
- PHP runtimes with CGI SAPI: You need to manually restart the PHP runtime.
- PHP runtimes with pre-forked worker processes: You need to manually restart the PHP master process.
You can automate the manual restarts required in the preceding cases and also change the way PHP sensor attempts to restart your PHP runtime by specifying a notification script for tracing.notificationScript in the com.instana.plugin.php section in the agent configuration.yaml file.
This setting takes the absolute path to an executable shell script (Linux) or PowerShell script (Windows). When a PHP runtime restart is needed, the PHP sensor executes the script defined in tracing.notificationScript instead of using its default restart commands.
Considerations for designing the notification script
The notification script runs once per PHP runtime, which means that the script might not be triggered for all processes running the same PHP executable file. To load the PHP Tracing extension into memory, you must make sure that your script restarts all the processes running from that PHP executable file.
When this script is configured and run successfully, it overrides the default mechanism for automatic restarts. Unlike the default mechanism, the script gets executed for any SAPI, so it can be used to automate restarts for PHP-CGI environments. If you want to disable automatic restarts completely, configure an empty script.
The PHP sensor sets the following environment variables for the script execution:
INSTANA_EXT_VERSION_OLD = the version of the tracing extension currently in memory
INSTANA_EXT_VERSION_NEW = the version of the tracing extension after a restart
INSTANA_PID_HOST = the PID of the process on the host, e.g. your Apache, PHP-FPM or PHP-CGI
INSTANA_PID_CONTAINER = the PID the host process has in a container (if applicable)
INSTANA_CONTAINER = the ID/name of the container the process is running in (if applicable)
The following example shows a script that logs extension changes to a file and restarts Apache:
#!/bin/bash
echo "Found new tracing extension." >> php_update.log;
echo "INSTANA_EXT_VERSION_OLD=$INSTANA_EXT_VERSION_OLD" >> php_update.log;
echo "INSTANA_EXT_VERSION_NEW=$INSTANA_EXT_VERSION_NEW" >> php_update.log;
echo "INSTANA_PID_HOST=$INSTANA_PID_HOST" >> php_update.log;
echo "INSTANA_PID_CONTAINER=$INSTANA_PID_CONTAINER" >> php_update.log;
echo "INSTANA_CONTAINER=$INSTANA_CONTAINER" >> php_update.log;
echo "restarting apache" >> php_update.log;
apachectl -k graceful >> php_update.log;
If your Apache runs inside a container, replace the last line in the sample script with the following line:
docker exec $INSTANA_CONTAINER apachectl -k graceful;
For PHP-FPM, you can send a SIGUSR2 to gracefully restart it as shown in the following example:
docker exec $INSTANA_CONTAINER kill -USR2 $INSTANA_PID_CONTAINER;
A graceful restart loads the PHP extension into memory without restarting the master process. So this loading works even when the process runs as PID 1 inside the container. If you cannot or do not want to use the restart approach, you can also create a snapshot of the running container instance, stop it, and open a new instance easily:
#!/bin/bash
IMAGE_HASH=$(docker inspect --format='{{.Config.Image}}' $INSTANA_CONTAINER)
IMAGE_NAME=$(docker images | grep $IMAGE_HASH | awk '{print $1}')
IMAGE_TAG="instana-php-$INSTANA_EXT_VERSION_NEW"
docker commit $INSTANA_CONTAINER $IMAGE_NAME:$IMAGE_TAG &&
docker stop $INSTANA_CONTAINER &&
docker run -d --rm $IMAGE_NAME:$IMAGE_TAG
This action uses the container ID passed to the script to find the name of the container image. It then commits the currently running container into a new image that is tagged with the new PHP extension version number. It then stops the original container and starts a container from the newly tagged image. While this action triggers the installation routine in the PHP sensor again, it does not trigger the notification script again because the extension is already installed.
These examples assume that you are using Docker as your container engine. But since the triggered shell script is completely under your control, you can put any logic that you need to make automatic restarts work for your setup.
Disabling PHP tracing
To disable PHP tracing, complete the following steps:
-
In the
com.instana.plugin.phpsection in the agentconfiguration.yamlfile, settracing.enabledtofalse. If the agentconfiguration.yamlfile does not have thecom.instana.plugin.phpsection, you need to add it as follows:com.instana.plugin.php: tracing: enabled: falseNote: Commenting thecom.instana.plugin.phpsection does not disable PHP tracing as it is enabled by default.The PHP sensor automatically removes the PHP Tracing extension's INI settings from the PHP INI configuration and attempts to gracefully restart the PHP runtime to remove the PHP Tracing extension from memory. After the PHP runtime is successfully restarted, PHP tracing is completely disabled.
-
If the PHP sensor cannot automatically restart the PHP runtime, manually restart the PHP runtime to completely disable PHP tracing. The ability of the PHP sensor to automatically restart the PHP runtime depends on the SAPI type. You can control this behavior and automate the PHP runtime restart that is needed to remove the PHP Tracer from memory. For more information, see Automatic restarts.
Note: You must read Automatic restarts and carefully consider if your PHP runtime needs to be manually restarted to remove the PHP Tracing extension from memory. -
Verify that the PHP Tracing extension is no longer enabled in your PHP runtime by checking that
instanais not listed in the list of extensions enabled in your PHP INI configuration. You can get the list of enabled PHP extensions by executing the PHP binary used by your PHP runtime with the option-m. The following example shows how to list the enabled PHP extensions by using thephp-fpmbinary:$> php-fpm -m [PHP Modules] curl json PDO sqlite3 Zend OPcache zlib [Zend Modules] Zend OPcacheNote: To confirm whether the PHP Tracing extension is disabled in Apache with themod_phpruntime, create a PHP script with the content<?php phpinfo();in the webserver's document root to make Apache serve the script. You can then open the URL to this script in your browser and verify thatinstanais not present in the list of enabled PHP extensions.If you encounter errors during this procedure, you can manually disable PHP tracing and uninstall the PHP Tracing extension. For more information, see Manually disabling PHP tracing.
Uninstalling the Instana agent does not automatically remove the PHP Tracing extension from the PHP runtimes that are already instrumented. Before you uninstall the Instana agent, disable the PHP tracing to uninstall the PHP Tracing extension from all PHP runtimes in the host. For more information, see Uninstalling the Instana agent.
Disabling PHP Tracing extension installation
To disable the automatic installation of the PHP Tracing extension in newly detected PHP runtimes, set tracing.installExtension to false in the com.instana.plugin.php section in the agent configuration.yaml file:
com.instana.plugin.php:
tracing:
enabled: true
installExtension: false
Troubleshooting
Absence of PHP traces in the Instana UI
If you use Plesk, you need to run plesk bin php_handler --reread.
If you don't see any traces appearing in the Instana UI for PHP applications, complete the following steps:
-
Verify the following prerequisites:
- The PHP sensor is enabled. For more information, see Disabling the PHP Tracing.
- The PHP Tracing extension binary is available. For more information, see Disabling the PHP Tracing extension.
- The PHP Tracing extension is enabled in the agent configuration file. For more information, see Removing the PHP Tracing extension file.
-
Reload the PHP Tracing extension by running the following
reloadcommand on the service that runs PHP applications:-
For Apache:
systemctl reload apache2 -
For PHP-FPM:
systemctl reload php<version>-fpmReplace <version> in the reload command with the actual version that is installed in the system.
-
If you still don't see any traces in the Instana UI and your operating system includes SELinux by default or adds it to the environment for security purposes, SELinux might be responsible for the issue.
The PHP Tracer extension communicates with the PHP daemon over the Unix TCP socket <socket path> and with the Instana agent over TCP/IP port 42699. When SELinux is set to enforcing mode, it prevents the PHP extension and daemon from communicating with each other unless SELinux is configured to allow it.
To verify whether SELinux is responsible for the issue, check /var/log/audit/audit.log for any silent denials that are recorded for the PHP daemon. Alternatively, you can do a smoke test by completing the following steps:
- Disable SELinux temporarily.
- Restart PHP daemon.
If SELinux is identified as the cause for the issue, you can resolve it by using any one of the following options:
-
Configure SELinux to allow PHP Tracer to communicate: With SELinux, you can follow your own security policies to configure a custom policy to allow for communication. For more information about creating and modifying SELinux policy, see the following links:
-
Set SELinux to permissive mode: In this mode, your services can operate without restrictions. You can restore the default setting by restarting the server. To set SELinux to permissive mode, see SELinux permissive mode.
-
Disable SELinux: Instana does not actively encourage you to disable security software. A right and safe approach is to create a SELinux policy. However, if you decide to disable SELinux, see Disable Linux.
Enabling logging
By default, logging is turned off. To enable it, refer to the following steps.
- Enable logging by using environment variables.
- To set the log level to debug, set
INSTANA_DEBUGtoTRUEorINSTANA_LOG_LEVEL=4
- Enable logging by using INI file.
-
Locate a file named
zzz-instana.iniin the scan directory of your PHP installation. For example, runningphp --ini | grep zzz-instana.iniorphp-fpm<version> -i | grep zzz-instana.inireveals its location. -
Add the line
instana.log_level=4tozzz-instana.ini. -
When you run the PHP runtime of your choice, make sure that some logging is present in the output and that the extension is enabled. For example, you can run
php --ri instanaorphp-fpm<version> -i | grep instanato verify.Example:
[instana.INFO] Initializing, logging at level 4 -
Reload the PHP tracing extension as described here. Skipping this step will ultimately result in no logging.
Logs are channeled into the PHP runtime the PHP tracing extension is installed into. Because of this, its precise location is highly dependent on its configuration. Usual locations include /var/log/apache2/error.log for Apache2 and /var/log/php<version>-fpm.log for PHP-FPM.
Manually installing PHP Tracing extension
To manually install the PHP Tracing extension, complete the following steps:
-
Download the Instana PHP Tracing extension as follows:
-
Download the shell script from the following repository:
https://artifact-public.instana.io/artifactory/shared/com/instana/php/instana-ext-download-script/php-instana-ext-download-script.sh -
Run the shell script to download the extension suitable for your environment. The following command shows the available options:
./php-instana-ext-download-script.sh -a <aarch64/x86_64> -l <musl/glibc> -p <PHP version> -t <NTS/ZTS> -d <serverless/native> -s <OpenSSL version> -v <Instana extension version>-
For the PHP version, provide major and minor version numbers. For example, to download the Instana extension for PHP 8.4.12, run the shell script with flag
-p 8.4. -
For the OpenSSL version, use the option
-s ssl1to download the extension that supports OpenSSL 1.1 or use-s ssl3to download the extension that supports OpenSSL 3.x. -
For the Instana extension version, the default value is
release, which downloads the latest version available. Use-vflag to download the artifact for any specific version. For example, run the script with-v 4.7.0to download the extension with the release version 4.7.0. -
To see all the options available for the script, run the following command:
./php-instana-ext-download-script.sh
-
-
-
Install the extension as follows:
-
Move the downloaded
.sofile to the PHP CLI extension directory. -
Create an INI file,
zzz-instana.ini, as shown in the following example, and save it to the PHP CLI additional INI directory. Replace<hostIP>with the IP address of the Instana agent host so that the agent is reachable from the PHP environment.; this file was automatically generated by Instana ; ; any changes made to this file are expected to be overwritten when ; a new version of the Instana PHP Tracer extension is installed [instana] extension=<php cli extension dir path where extension.so file is placed> instana.socket=<hostIP>:16816 instana.agent_endpoint=http://<hostIP>:42699 instana.use_agent_endpoint=1 instana.auto_profile_socket=tcp://<hostIP>:42699 instana.enable_auto_profile=0 instana.secrets_matcher=contains-ignore-case instana.secrets_list="key,pass,secret" instana.extra_http_headers= instana.pid_in_root_namespace=<pid of PHP process in hostnamespace> instana.enable_cli=1
-
Manually disabling PHP tracing
Following the steps outlined in Disabling PHP tracing disables PHP tracing completely, including removal of the PHP Tracing extension from your PHP runtime.
If you encounter errors during this procedure and you want to manually disable PHP tracing and uninstall the PHP Tracing extension, complete the following steps:
-
Make sure that PHP tracing is disabled in the agent
configuration.yamlfile as follows:com.instana.plugin.php: tracing: enabled: falseThis configuration prevents the PHP sensor from reinstalling the PHP Tracing extension again.
-
Disable the PHP Tracing extension in your PHP INI configuration. See Disabling the PHP Tracing extension.
-
Remove the PHP Tracing extension file from your system. See Removing the PHP Tracing extension file.
Disabling the PHP Tracing extension
When the PHP sensor installed the extension, it also enabled the extension for your PHP installation. Enabling the extension means that the PHP sensor either placed the zzz-instana.ini file into your Additional Ini files folder or enabled it directly in your php.ini.
To find out where it was enabled, run the PHP binary for which you enabled tracing. The following example shows this with a PHP-FPM binary:
$> php-fpm7.0 -i | egrep "^(Scan|Loaded)"
Loaded Configuration File => /etc/php/7.0/fpm/php.ini
Scan this dir for additional .ini files => /etc/php/7.0/fpm/conf.d
In this example, the zzz-instana.ini file is located in /etc/php/7.0/fpm/conf.d. If no Additional Ini files folder is available, or the zzz-instana.ini file does not exist at that location, check your php.ini instead. In this example, the file is in /etc/php/7.0/fpm/php.ini.
On Windows, run the following command in PowerShell to get the location of the php.ini file or the location of the Additional Ini files folder for PHP-CGI:
PS C:\> php-cgi -i | Select-String -Pattern '(Scan|Loaded Configuration)' | ForEach-Object { ($_ -replace '<br\s*/?>', "`n") -replace '<[^>]+>', ''}
Loaded Configuration File C:\Php\php.ini
Scan this dir for additional .ini files (none)
<?php phpinfo(); into a web accessible location on Apache and open it in a browser for the same information.To disable the PHP tracing extension, complete the following steps:
-
Open the appropriate
inifile in an editor and prefix the semicolon (;) in the lineextension=/path/to/instana.soas follows. Adding a semicolon comments out the line.;extension=/path/to/instana.soAlternatively, remove the line
extension=/path/to/instana.soaltogether. Do not remove it if you intend to enable the extension at a later point. -
If you have the
zzz-instana.inifile, you can also remove the file completely as follows:$> sudo rm /etc/php/7.0/fpm/conf.d/zzz-instana.iniOn Windows, you can remove the file by running the following command in PowerShell (as Administrator):
PS C:\> Remove-Item -Path C:\Php\conf\zzz-instana.iniImportant: Do not remove your entirephp.inifile. -
Restart your PHP runtime to remove the PHP Tracing extension from memory. If your PHP runtime uses pre-forked workers, you need to restart the PHP master process now.
Removing the PHP Tracing extension file
PHP logs startup errors when it cannot find an extension, so before you remove the extension, you must also disable it. For more information, see Disabling the PHP Tracing extension.
The PHP sensor places the Instana PHP tracing extension into the directory that is given in the extension_dir setting in your php.ini. To find out the setting, run the PHP binary for which you enabled tracing. The following example shows this with a PHP-FPM binary:
$> php-fpm7.0 -i | egrep ^extension_dir
extension_dir => /usr/lib/php/20151012 => /usr/lib/php/ext
<?php phpinfo(); into a web accessible location on Apache and open it in a browser for the same information.The PHP sensor uses only the first value, so in the example, you can find the extension at /usr/lib/php/20151012. The path to the extension is also given in your php.ini or the zzz-instana.ini file.
On Windows, you can run the following command in PowerShell to find out extension_dir:
PS C:\> php-cgi -i | Select-String -Pattern 'extension_dir' | ForEach-Object { ($_ -replace '<br\s*/?>', "`n") -replace '<[^>]+>', ' '}
extension_dir C:\php\ext C:\php\ext
To remove the extension, run the following command:
$> sudo rm /usr/lib/php/20151012/instana.so
On Windows, you can remove the file by running the following command in PowerShell (as administrator):
PS C:\> Remove-Item -Path C:\Php\ext\instana.dll
If you are using pre-forked workers and did not already restart your PHP master process when you disabled the extension, you need to restart it for the changes to take effect.