php client for jaeger

Installs: 90 708

Dependents: 1

Suggesters: 0

Security: 0

Stars: 4

Watchers: 1

Forks: 116


Tests Minimum PHP Version License Coverage Status

ATTENTION: this is a fork and republication of jukylin/jaeger-php

We opted into forking and publishing the original library in order to maintain our set of opentracing related symfony bundles. The original library seems to be unmaintained currently.

jaeger-php is a library implementing the OpenTracing specification for PHP to connect with the Jaeger Distributed Tracing Platform. It can be used to instrument PHP code to generate tracing data and send it to Jaeger.


composer require auxmoney/jaeger-php


First, you need to create a Config object, which serves as the factory to create your Tracer:

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

To make the distributed tracing work, you need to extract your SpanContext from somewhere, e.g. $_SERVER:

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

You can then start tracing by using the common Opentracing interface:

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

To add metadata to your span, you need to retrieve it first (be sure to check the semantic conventions first):

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

Finally, at the end of your script, you should flush the original Config. This will flush all created Tracers and all created Spans:


optional configuration

// optional: generate 128 bit trace ids (default: false)
// optional: disable tracing (default: false)
// optional: inject custom transport (default: TransportUdp)
// optional: inject custom reporter (default: RemoteReporter)
// optional: inject custom sampler (default: ConstSampler)

Special thanks

Thank you, @jukylin, for creating this library!