PHP code example of opentelemetry-manager / laravel

1. Go to this page and download the library: Download opentelemetry-manager/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/ */

    

opentelemetry-manager / laravel example snippets


 use OpenTelemetryManager\Supports;

$parent = OpenTelemetry::startSpan("parent")

    $child = OpenTelemetry::startSpan("child")
 
    $child->end();

$parent->end();

//for detach active span ( call in end of the execution )
OpenTelemetry::end()

use OpenTelemetryManager\Supports;


$outgoing = OpenTelemetry::startSpan('Start remote Request');

   $response = Http::withHeaders(OpenTelemetry::outGoingPropagationHeader())
            ->get('url');

$outgoing->end();
 
 
//for detach active span ( call in end of the execution )
OpenTelemetry::end()

use OpenTelemetryManager\Supports;


$context = OpenTelemetry::incomingPropagation($request->header());

$span = OpenTelemetry::startSpan('Start second App', $context);

$span->end();
 
 
//for detach active span ( call in end of the execution )
OpenTelemetry::end()