04/07
2017
dev-master
9999999-dev
MIT
The Requires
The Development Requires
Wallogit.com
2017 © Pedro Peláez
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();
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);
$logger = new HttpLogger($zipkinHost); $tracer = new Tracer($logger); // ... $tracer->send();
If you want to cut off the tracer your can use our NoopTracer, (*4)
$logger = new NoopLogger($zipkinHost); $tracer = new Tracer($logger); // ... $tracer->send();
MIT