PHP code example of ellis / jaeger-client
1. Go to this page and download the library: Download ellis/jaeger-client 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/ */
ellis / jaeger-client example snippets
use Ellis\Jaeger\Reporter\RemoteReporter;
use Ellis\Jaeger\Sampler\ConstSampler;
use Ellis\Jaeger\Tracer;
use Ellis\Jaeger\Transport\UdpTransport;
use OpenTracing\GlobalTracer;
$transport = new UdpTransport('127.0.0.1', 6831);
$reporter = new RemoteReporter($transport);
$sampler = new ConstSampler(true);
$tracer = new Tracer('my-service', $reporter, $sampler);
// Other libraries may try to get open tracing implementation from GlobalTracer
// so setting your tracer instance to GlobalTracer is a good practice.
GlobalTracer::set($tracer);
// Make sure we gracefully close Tracer on any situation
register_shutdown_function(function (Tracer $tracer, LoggerInterface $logger) {
try {
@$tracer->close();
} catch (\Exception $e) {
$logger->warn('Failed closing Tracer: '.$e->getMessage());
}
}, $tracer, $logger);