PHP code example of auxmoney / jaeger-php

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

    

auxmoney / jaeger-php example snippets


// create a config instance
$config = \Jaeger\Config::getInstance();
// create a tracer
$tracer = $config->initTracer('example service name', '0.0.0.0:6831');

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

$tracer->startActiveSpan("example operation name", ['child_of' => $spanContext]);

$span = $tracer->getActiveSpan();
$span->addBaggageItem("user_id", "12345");
$span->setTag("http.url", "http://localhost");
$span->log(["message" => "responded successfully"]);
$span->finish();

$config->flush();

// optional: generate 128 bit trace ids (default: false)
$config->gen128bit();
// optional: disable tracing (default: false)
$config->setDisabled(true);
// optional: inject custom transport (default: TransportUdp)
$config->setTransport($transport);
// optional: inject custom reporter (default: RemoteReporter)
$config->setReporter($reporter);
// optional: inject custom sampler (default: ConstSampler)
$config->setSampler($sampler);

composer