Custom Instrumentation
  • Updated on 09 Jul 2019
  • 1 minute to read
  • Contributors
  • Print
  • Share
  • Dark
    Light

Custom Instrumentation

  • Print
  • Share
  • Dark
    Light

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"
    }
  ]
}

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 for more details on setting up a PHP CLI application.

Was this article helpful?