Laravel

Laravel 4 and 5 are supported out of the box in Tideways for automatic transaction detection and instrumentation of events, templates, bootstrapping and controllers. In addition several Eloquent query APIs for SELECT, UPDATE, INSERT and DELETE are instrumented.

To configure the transaction detection you have to configure the framework as laravel, for example in .ini:

tideways.framework=laravel

The following Laravel code blocks are instrumented automatically by the PHP extension:

  • Events dispatched through event() or Illuminate\\Events\\Dispatcher::fire

  • Templates rendered with the Blade template engine

  • Controllers

  • Duration of boot

  • Session middleware cleanup/garbage collection

  • Eloquent Queries

    • SELECT queries executed through Illuminate\Database\Eloquent\Builder::getModels

    • Write operations performed through Illuminate\Database\\Eloquent\Model methods performInsert, performUpdate, delete and destroy.

Laravel Queue instrumentation

If you are making use of the Laravel Queues feature, then instrumenting the duration of individual jobs inside the workers can increase insight into the performance of your background jobs.

Instrumentation of worker jobs has to be integrated manually at the moment, not automatic support exists yet. You need to hook into the before, after and failing events, for example from an AppServiceProvider or from a dedicated Tideways service provider:

<?php
declare(strict_types=1);

namespace App\Providers;

use Tideways\Profiler;

class TidewaysProvider extends ServiceProvider
{
    private $sampleRate = 10;
    private $service = 'worker';

    public function boot()
    {
        if (!class_exists('Tideways\Profiler')) {
            return;
        }

        Queue::before(function (JobProcessing $event) {
            Profiler::start(array(
                'sample_rate' => $this->sampleRate
            ));
            Profiler::setServiceName($this->service);
            Profiler::setTransactionName($event->job->resolveName());
        });

        Queue::after(function (JobProcessed $event) {
            Profiler::stop();
        });

        Queue::failing(function (JobFailed $event) {
            Profiler::logException($event->exception);
        });
    }

    public function register()
    {
    }
}

Register the TidewaysProvider in config/app.php file by adding it to the providers key in the array:

'providers' => [
    // Other Service Providers
    App\Providers\TidewaysProvider::class,
],
Still need help? Email [email protected]