PHP code example of jcchavezs / zipkin-opentracing
1. Go to this page and download the library: Download jcchavezs/zipkin-opentracing 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/ */
jcchavezs / zipkin-opentracing example snippets
use OpenTracing\GlobalTracer;
use Psr\Log\NullLogger;
use Zipkin\Endpoint;
use Zipkin\Samplers\BinarySampler;
use Zipkin\TracingBuilder;
use Zipkin\Reporters\Http;
$endpoint = Endpoint::create('my_service', '127.0.0.1', null, 8081);
$reporter = new Zipkin\Reporters\Http();
$sampler = BinarySampler::createAsAlwaysSample();
$tracing = TracingBuilder::create()
->havingLocalEndpoint($endpoint)
->havingSampler($sampler)
->havingReporter($reporter)
->build();
$zipkinTracer = new ZipkinOpenTracing\Tracer($tracing);
GlobalTracer::set($zipkinTracer); // optional
use OpenTracing\GlobalTracer;
$application->run();
register_shutdown_function(function() {
GlobalTracer::get()->flush();
});