---
title: "PHP Custom Instrumentation"
slug: "php-custom-instrumentation"
updated: 2020-12-11T14:48:40Z
published: 2020-12-11T14:48:40Z
---

> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stackify.com/llms.txt
> Use this file to discover all available pages before exploring further.

# PHP Custom Instrumentation

## Configuration

**Custom Instrumentation** allows you to track classes and functions not natively supported in our PHP Profiler. Include a `stackify.json` file in your application's `DOCUMENT_ROOT`.

**Example:**

```
{
  "instrumentation": [
    {
      "class": "SampleClass1",
      "method": "execute"
    },
    {
      "class": "SampleClass2",
      "method": "index"
    }
  ]
}
```

          NOTE:

          

If you are trying to track methods in procedural code that has no class, you can leave the class empty.

```
{
  "instrumentation": [
    {
      "class": "",
      "method": "sample_function"
    }
  ]
}
```

**Custom Instrumentation** is supported in the **Stackify PHP profiler 1.3+** versions.

Optionally, you may specify the location of `stackify.json` by adding `stackify.config_file=[stackify.json path]` to your `php.ini`.

**Example:**

```
[stackify]
extension=stackify.so
stackify.application_name=PHP Application
stackify.environment_name=Production
stackify.config_file=/var/www/html/stackify.json
```

## Tracked Functions

**Tracked Functions** allows you track a specific method call across requests, data will show up in your application dashboard under the **Tracked Functions** tab.

**Example:**

```
{
  "instrumentation": [
    {
      "class": "SampleClass1",
      "method": "execute",
      "trackedFunction": true,
      "trackedFunctionName": "{{ClassName}}.{{MethodName}}"
    },
    {
      "class": "SampleClass2",
      "method": "index",
      "trackedFunction": true,
      "trackedFunctionName": "{{ClassName}}.{{MethodName}}"
    }
  ]
}
```

## Custom Trace Entry Point

**Custom Trace Entry Points** are useful when profiling a **PHP CLI** application. By default each PHP file execution is tracked as a transaction. The following configuration allows you to detail a specific method to override this default behavior. This can be helpful when you have a long running PHP script that spawns multiple transactions (such as monitoring a queue).

```
{
  "instrumentation": [
    {
      "class": "QueueProcessor",
      "method": "processMessage",
      "startTrace": true
    }
  ]
}
```

See [PHP CLI Support](https://docs.stackify.com/docs/advanced-configuration#php-cli-support) for more details on setting up a **PHP CLI** application.
