PHP code example of bethinkpl / elastic-apm-laravel

1. Go to this page and download the library: Download bethinkpl/elastic-apm-laravel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bethinkpl / elastic-apm-laravel example snippets




use PhilKra\ElasticApmLaravel\Providers\ElasticApmServiceProvider;
use GuzzleHttp\HandlerStack;

$handler = HandlerStack::create();
$handler->push(ElasticApmServiceProvider::getGuzzleMiddleware());

// create your client with 'handler' option passed

protected $middleware = [
    // ... more middleware
    \PhilKra\ElasticApmLaravel\Middleware\RecordTransaction::class,
];

$app->middleware([
    PhilKra\ElasticApmLaravel\Middleware\RecordTransaction::class
]);

$app->register(\PhilKra\ElasticApmLaravel\Providers\ElasticApmServiceProvider::class);

// Use any normal Laravel method of resolving the dependency
$transaction = app(\PhilKra\ElasticApmLaravel\Apm\Transaction::class);

$span = $transaction->startNewSpan('My Span', 'app.component_name');

// do some stuff

$span->end();

ElasticApm::captureThrowable($exception);
ElasticApm::send();

use ElasticApm;
bash
php artisan vendor:publish --tag=config