Hi everyone,
I'm in the middle of implementing tracing for our vert.x 3.3.2 application and I'm currently stuck with passing along the traceId and parentSpanId to other verticles when using Java proxies.
What already works:
HTTPEndpoint verticle receives events via SockJS bridge and starts tracing (brave.serverTracer().setStateUnknown( .... )). The resulting parentSpanId is set as a header in DeliveryOptions:
DeliveryOptions deliveryOptions = new DeliveryOptions().addHeader("__spanId", ""+parentSpanId) .addHeader("__traceId", ""+parentSpanId);
eventBus.publish("testChannel", msg, deliveryOptions);
The receiving verticle then extracts the values and traces its own call:
Long parentSpanId = Long.valueOf(msg.headers().get("__spanId"));
Long traceId = Long.valueOf(msg.headers().get("__traceId"));
// ...
brave.serverTracer().setStateCurrentTrace(traceId, spanId, parentSpanId, methodName);
This works -- Zipkins shows the trace as a chain of calls from HTTPEndpoint to the receiving verticle.
My questions:
(1) Our application makes heavy use of the auto-generated Java proxies for inter-verticle communication. How would I transport the tracing information from verticle A to verticle B then (A calls B)?
(2) Is there a better way than setting deliveryOptions to transport header when using send / publish? Adding an interceptor to eventBus and then call event.message().headers.add("__spanId", ""+id); ? What makes more sense in terms of overhead?
Thanks, Tim