jukylin / jaeger-php

Jaeger Bindings for PHP OpenTracing API
https://github.com/jaegertracing/jaeger
Apache License 2.0
225 stars 81 forks source link
distributed-tracing istio jaeger opentracing php-client zipkin

Build Status Minimum PHP Version License Coverage Status

jaeger-php

Install

Install via composer.

composer config minimum-stability dev
composer require jukylin/jaeger-php

Init Jaeger-php

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

128bit

$config->gen128bit();

Extract from Superglobals

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

Start Span

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

Distributed context propagation

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

Inject into Superglobals

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

Tags and Log

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

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

Close Tracer

$config->setDisabled(true);

Zipkin B3 Propagation

no support for Distributed context propagation

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

Finish span and flush Tracer

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

More example

Features

Reference

OpenTracing

Jaeger