newrelic_add_custom_tracer(string $function_name)
Specify functions or methods for the agent to instrument with custom instrumentation.

Description

Specify functions or methods for the agent to target for custom instrumentation. This is the API equivalent of the newrelic.transaction_tracer.custom setting.

You cannot apply custom tracing to internal PHP functions.

Parameters

Parameter Description

$function_name

string

Required. The name can be formatted either as function_name for procedural functions, or as "ClassName::method" for methods. Both static and instance methods will be instrumented if the method syntax is used.

Return value(s)

Returns true if the tracer was added successfully.

Example(s)

Instrument a function

function example_function(
    if (extension_loaded('newrelic')) { // Ensure PHP agent is available
		function newrelic_add_custom_tracer("example_function")
    }
)

Instrument a method within a class

Class ExampleClass {
    function example_method(){
        if (extension_loaded('newrelic')) { // Ensure PHP agent is available
    	    newrelic_add_custom_tracer("ExampleClass::example_method");
        }
    }
}