Trigger Callgraph when Function/Method Called

These methods are only available with Tideways Extension Version 5.0.46 and higher. Please upgrade the extension to the latest version before using this API.

If you want to force callgraph collection for a function or method call in your application, then place the following code line in your application code, before this method is called. A good location is in your index.php or a boostrap script. If you don’t need performance data on all the child functions, then look at the custom timespan API to create an entry in the timeline.

<?php

if (class_exists('Tideways\Profiler')) {
    $observeMethod = 'Namespace\Class::method';
    \Tideways\Profiler::triggerCallgraphOn($observeMethod);
}

For example to trigger a Callgraph by observing the Symfony-Framework-method Request::createFromGlobals() method:

<?php

if (class_exists('Tideways\Profiler')) {
    \Tideways\Profiler::triggerCallgraphOn(
        'Symfony\Component\HttpFoundation\Request::createFromGlobals'
    );
}

// here your application code
Request::createFromGlobals();

The observe method argument must contain the fully qualified class namespace and method separated with :: . This syntax is used for both static and for not static methods.

If the observed method is called multiple times in the same request, then data of the callgraph is aggregated for all the calls of this method.

The timeline trace display line named "callgraph-start" marking the moment the callgraph profiler was started because your method was called.

image

And this screenshot shows the callgraph with the observed method createFromGlobals() from the example :

image

To observe a function and trigger a callgraph, pass the function name as string argument to the API-Call like this:

<?php

if (class_exists('Tideways\Profiler')) {
    \Tideways\Profiler::triggerCallgraphOn('mytest');
}

Again the timeline shows markers for every time the observed function was called.

image
image
Still need help? Email [email protected]