Add Custom Metadata to Trace

You can add custom metadata to every collected trace in Tideways, which will then be sent and displayed in the Timeline Tracer UI.

The API is very simple, just call \Tideways\Profiler::setCustomVariable($name, $value).

Let’s assume we have an endpoint in our application that processes small to a large amount of datasets. The number of datasets obviously affects the runtime, so why not display how many were part of the request?



use Tideways\Profiler;

class ImportController
    public function importAction()
        $items = $this->parseItemsFromRequest();
        if (class_exists('Tideways\Profiler')) {
            Profiler::setCustomVariable('imported_items', count($items));

This Screenshot shows you, how Metadata displayed in the Timeline Tracer UI.


You don’t have to check if the Profiler is currently tracing the full request or just a sample, the internal API knows when to keep or discard the custom variables.

Still need help? Email [email protected]