Instrument a PHP application for Splunk Observability Cloud π
The SignalFx Tracing Library for PHP automatically instruments PHP applications.
To get started, use the guided setup or follow the instructions manually.
Generate customized instructions using the guided setup π
To generate all the basic installation commands for your environment and application, use the PHP guided setup. To access the PHP guided setup, follow these steps:
Log in to Observability Cloud.
Open the PHP guided setup. Optionally, you can navigate to the guided setup on your own:
In the left navigation menu, select
.Select Add Integration to open the Integrate Your Data page.
In the integration filter menu, select By Product.
Select the APM product.
Select the PHP tile to open the PHP guided setup.
Instrument a PHP application π
Follow these steps to automatically instrument your application:
Check that you meet the requirements. See PHP instrumentation compatibility and requirements.
Download the installation script from the following location:
curl -LO https://github.com/signalfx/signalfx-php-tracing/releases/latest/download/signalfx-setup.php
Install by running the installation script:
php signalfx-setup.php --php-bin=all
Note
If you omit the
--php-bin
option, you can interactively select the PHP installation.Set the following environment variables:
# Add the following lines to your Apache configuration file SetEnv SIGNALFX_SERVICE_NAME="<my-service-name>" SetEnv SIGNALFX_ENDPOINT_URL='http://localhost:9080/v1/trace' SetEnv SIGNALFX_TRACE_GLOBAL_TAGS="deployment.environment<my_environment>"
export SIGNALFX_SERVICE_NAME="<my-service-name>" export SIGNALFX_ENDPOINT_URL='http://localhost:9080/v1/trace' export SIGNALFX_TRACE_GLOBAL_TAGS="deployment.environment:<my_environment>"
Caution
Set environment variables globally or using the start script of your PHP application.
Restart your server.
Note
If you need to add custom attributes to spans or want to manually generate spans, instrument your PHP application or service manually. See Manually instrument PHP applications for Splunk Observability Cloud.
INI file settings π
If you donβt set any environment variable, the library extracts default values from the INI file. The prefix for settings defined using environment variables that start with SIGNALFX_TRACE_
is signalfx.trace.
. For all other environment variables that start with SIGNALFX_
the prefix is signalfx.
.
You can use the signalfx-setup.php
script to set INI file options without having to manually locate each file. For example:
php signalfx-setup.php --update-config --signalfx.endpoint_url=http://172.17.0.1:9080/v1/trace
This is useful for options common to all PHP services running in the system, like endpoints.
Deploy the PHP instrumentation in Kubernetes π
To deploy the PHP instrumentation in Kubernetes, configure the Kubernetes Downward API to expose environment variables to Kubernetes resources.
The following example shows how to update a deployment to expose environment variables by adding the agent configuration under the .spec.template.spec.containers.env
section:
apiVersion: apps/v1
kind: Deployment
spec:
selector:
matchLabels:
app: your-application
template:
spec:
containers:
- name: myapp
env:
- name: SIGNALFX_PHP_LIBRARY
valueFrom:
fieldRef:
fieldPath: status.hostIP
- name: SIGNALFX_SERVICE_NAME
value: "<service-name>"
- name: SIGNALFX_ENDPOINT_URL
value: "http://<endpoint>:9080/v1/trace"
- name: SIGNALFX_TRACE_GLOBAL_TAGS
value: "deployment.environment:<my_environment>"
Send data directly to Observability Cloud π
By default, all telemetry is sent to the local instance of the Splunk Distribution of OpenTelemetry Collector.
To bypass the OTel Collector and send data directly to Observability Cloud, set the following environment variables:
SetEnv SIGNALFX_ACCESS_TOKEN=<access_token>
SetEnv SIGNALFX_ENDPOINT_URL=https://ingest.<realm>.signalfx.com/v2/trace/signalfxv1
export SIGNALFX_ACCESS_TOKEN=<access_token>
export SIGNALFX_ENDPOINT_URL=https://ingest.<realm>.signalfx.com/v2/trace/signalfxv1
To obtain an access token, see Retrieve and manage user API access tokens using Splunk Observability Cloud.
In the ingest endpoint URL, realm
is the Observability Cloud realm, for example, us0
. To find the realm name of your account, follow these steps:
Open the left navigation menu in Observability Cloud.
Select
.Select your username.
The realm name appears in the Organizations section.
Note
For more information on the ingest API endpoints, see Send APM traces.