Trace your micro-services oriented application with
Zipkin and OpenTracing
CNCF Italy - Turin
Walter Dal Mut
github.com/wdalmut
twitter.com/walterdalmut
corley.it
3 Foundations
Logging
Too much details for realtime reading
Monitor
Aggretate
Measure Changes
Measure Changes (2)
Annotate things
(distributed)
Tracing
Tracing is about Spans, inter-process propagation
and active span management
Spans
Inter-process propagation
X-B3-TraceId: 1250938620936823095802313
X-B3-SpanId: 12435243758
X-B3-ParentSpanId: 1245675313
X-B3-Sampled: 1
ZipKin
zipkin.io
List/Filter operations
Underline errors
K/V store
Intra-services errors
open this trace
KV on errors
Events
Client Send - Server Receive and Events
Service dependencies
PHP ZipKin support library
https://github.com/wdalmut/php-zipkin
Create span 2annotations(sr,ss)
$span = new ServerReceive(
"get_users", // method name
"oauth2", // service name
"auth.corley:80" // IP:Port
);
$span->sent();
Create span 2annotations(cs,cr)
$span = new ClientSend(
"get_users", // method name
"oauth2", // service name
"auth.corley:80" // IP:Port
);
$span->receive();
Set as a child span
$span->childOf($parentSpan);
Get an existing span
$span = $tracer->findOneBy("kind", "root");
Use K/V store
$span
->getBinaryAnnotations()
->set("error", true);
Create an event annotation
$span->add("an_event");
Use your framework to instrument your app
https://github.com/wdalmut/opentracing-bundle
Query trace
thanks to doctrine events
doctrine:
dbal:
logging: true
Trace other services (cs,cr)
thanks to Guzzle middleware
http.handler:
class: GuzzleHttpHandlerCurlHandler
http.stack:
class: GuzzleHttpHandlerStack
calls:
- ["setHandler", ["@http.handler"]]
tags:
- { name: corley.auth.guzzle_handler_stack }
http.client:
class: GuzzleHttpClient
arguments:
- {"handler": "@http.stack"}
My biggest mistake...
too many spans (use sr,cs,ss,cr for the same span)
too much details (span name
/v1/user/walter.dalmut@gmail.com)
Conclusion
Measure is the key to science
Richard Feynman

Trace your micro-services oriented application with Zipkin and OpenTracing