sinopower / jaeger-php

Jaeger Bindings for PHP OpenTracing API

Home Page:https://github.com/jaegertracing/jaeger

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status Minimum PHP Version License Coverage Status

jaeger-php

Install

Install via composer.

vim composer.json

{
  "minimum-stability": "dev",
  "require": {
    "jukylin/jaeger-php" : "^2.0",
    "opentracing/opentracing":"1.0.0-beta5"
  }
}

composer update

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

  • Transports

    • via Thrift over UDP
  • Sampling

    • ConstSampler
    • ProbabilisticSampler

Reference

OpenTracing

Jaeger

About

Jaeger Bindings for PHP OpenTracing API

https://github.com/jaegertracing/jaeger

License:Apache License 2.0


Languages

Language:PHP 100.0%