Skip to content

Instantly share code, notes, and snippets.

@patforna
Created May 29, 2014 16:10
Show Gist options
  • Save patforna/a77f9c02c39ec47914d3 to your computer and use it in GitHub Desktop.
Save patforna/a77f9c02c39ec47914d3 to your computer and use it in GitHub Desktop.
// service A
val tracer = ZipkinTracer.mk(host = "localhost", port = 9410, sampleRate = 1)
Trace.unwind {
Trace.pushTracerAndSetNextId(tracer)
Trace.recordRpcname("service-A", "GET")
Trace.record(Annotation.ServerRecv())
// client call to service B (see below)
Trace.record(Annotation.ServerSend())
}
// service A - client call to service B
Trace.unwind {
Trace.setId(Trace.nextId)
Trace.recordRpcname("service-B", "GET")
// set http headers
Trace.record(Annotation.ClientSend())
// make http call
Trace.record(Annotation.ClientRecv())
}
// service B
val tracer = ZipkinTracer.mk(host = "localhost", port = 9410, sampleRate = 1)
Trace.unwind {
Trace.pushTracer(tracer)
// parse HTTP headers
Trace.setId(TraceId(traceId, parentSpanId, sid, sampled, flags))
Trace.recordRpcname("service-B", "GET")
Trace.record(Annotation.ServerRecv())
// Trace.record("received")
// do some work
// Trace.record("sent")
Trace.record(Annotation.ServerSend())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment