2017 © Pedro Peláez
 

library php-zipkin

image

wdalmut/php-zipkin

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 2 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

PHP ZipKin

Build Status, (*1)

A simple ZipKin implementation to trace your microservices based application, (*2)

// create the root span as server receive
$otherSpan = new ServerReceive("get_users", "oauth2", "auth.corley:80");
// add span to the tracer
$tracer->addSpan($otherSpan);

// restore the root span using headers (X-B3-TraceId, X-B3-SpanId, X-B3-ParentSpanId)
$otherSpan->restoreContextFromHeaders($request);

// add a binary annotation on this span
$otherSpan->getBinaryAnnotations()->set("http.method", "GET");

// create a new span (service call)
$span = new ClientSend("getVipUser", "oauth2");
// set span as child of the root span
$span->childOf($otherSpan);
// add span to the tracer
$tracer->addSpan($span);

// add binary annotation on this span
$span->getBinaryAnnotations()->set("error", true);

// sign a custom event on the current span
$span->add("reservedCustomer);

// close the client send span
$span->receive();

// close the server sent span
$otherSpan->sent();

Search for a Span

When you change your context may you lost a span reference. You can use your binary annotation to search for a particular span, (*3)

$rootSpan = $tracer->findOneBy("kind", "app.flow");

$span = new ClientSend("getUsers", "user.corley");
$span->setChildOf($rootSpan);

Send data using the tracer

$logger = new HttpLogger($zipkinHost);
$tracer = new Tracer($logger);

// ...

$tracer->send();

Noop tracer

If you want to cut off the tracer your can use our NoopTracer, (*4)

$logger = new NoopLogger($zipkinHost);
$tracer = new Tracer($logger);

// ...

$tracer->send();

The Versions

04/07 2017

dev-master

9999999-dev

  Sources   Download

MIT

The Requires

 

The Development Requires