Skip to content
Jaeger Bindings for PHP OpenTracing API
PHP Shell
Branch: master
Clone or download

Build Status PHP version

Jaeger Bindings for PHP OpenTracing API

This is a client-side library that can be used to instrument PHP apps for distributed trace collection, and to send those traces to Jaeger. See the OpenTracing PHP API for additional detail.

Contributing and Developing

Please see


Jaeger client can be installed via Composer:

composer require jonahgeorge/jaeger-client-php

Getting Started


require_once 'vendor/autoload.php';

use Jaeger\Config;
use OpenTracing\GlobalTracer;

$config = new Config(
        'sampler' => [
            'type' => Jaeger\SAMPLER_TYPE_CONST,
            'param' => true,
        'logging' => true,

$tracer = GlobalTracer::get();

$scope = $tracer->startActiveSpan('TestSpan', []);



List of supported samplers, for more info about samplers, please read Jaeger Sampling guide.

Const sampler

This sampler either samples everything, or nothing.

'sampler' => [
    'type' => Jaeger\SAMPLER_TYPE_CONST,
    'param' => true, // boolean wheter to trace or not

Probabilistic sampler

This sampler samples request by given rate.

'sampler' => [
    'param' => 0.5, // float [0.0, 1.0]

Rate limiting sampler

Samples maximum specified number of traces (requests) per second.

  • psr/cache PSR-6 cache component to store and retrieve sampler state between requests. Cache component is passed to Jaeger\Config trough its constructor.
  • hrtime() function, that can retrieve time in nanoseconds. You need either php 7.3 or PECL/hrtime extension.
'sampler' => [
    'type' => Jaeger\SAMPLER_TYPE_RATE_LIMITING,
    'param' => 100 // integer maximum number of traces per second,
    'cache' => [
        'currentBalanceKey' => 'rate.currentBalance' // string
        'lastTickKey' => 'rate.lastTick' // string


Tests are located in the tests directory. See tests/



MIT License.

You can’t perform that action at this time.