PHP code example of pnal / jaeger-php

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

    

pnal / jaeger-php example snippets



use Jaeger\Factory;
use OpenTracing\Formats;

// init factory
$factory = Factory::getInstance();
// make OpenTracing\Tracer instance
$tracer = $factory->initTracer('user', '127.0.0.1', 6831);

// extract parent infomation from http header
$carrier = $_SERVER['HTTP_UBER_TRACE_ID'];
// extract the infomation and generate a new context
// only support binary carrier now
$context = $tracer->extract(Formats\BINARY, $carrier);

// make a new span
$span = $tracer->startSpan('foo', ['child_of' => $context]);

// do your job here

// finish the span
$span->finish();

// report infomation to jaeger
$tracer->flush();

cd example
php -S 0.0.0.0:8080 HTTP.php

cd example
php Hprose.php