PHP code example of itshayu / jaeger-php

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

    

itshayu / jaeger-php example snippets


$config = Config::getInstance();
$tracer = $config->initTracer('example', '0.0.0.0:6831');

$config->gen128bit();

$spanContext = $tracer->extract(Formats\TEXT_MAP, $_SERVER);

$serverSpan = $tracer->startSpan('example HTTP', ['child_of' => $spanContext]);

$serverSpan->addBaggageItem("version", "2.0.0");

$clientTrace->inject($clientSpan1->spanContext, Formats\TEXT_MAP, $_SERVER);

// tags are searchable in Jaeger UI
$span->setTag('http.status', '200');

// log record
$span->log(['error' => 'HTTP request timeout']);

$config->setDisabled(true);

$config::$propagator = \Jaeger\Constants\PROPAGATOR_ZIPKIN;

$span->finish();
$config->flush();