I am trying to link three HTTP service hops in NodeJS together into a single Zipkin trace. I have three services
service-main
service-hello
service-goodbye
The service service-main
calls service-hello
, and service-hello
needs to call service-goodbye
to complete. Zipkin can see these calls, but links them together as two separate traces. (service-main
calling service-hello
, and service-hello
calling service-goodbye
.
The services are implemented in express
, and the fetching happens via node-fetch
.
I create an instrumented service fetcher with code that looks like this
const createFetcher = (remoteServiceName, tracer) => {
const wrapFetch = require('zipkin-instrumentation-fetch');
return wrapFetch(fetch,
{
tracer:tracer,
remoteServiceName:remoteServiceName
}
);
}
and I instrument express with code that looks like this
app.use(zipkinMiddleware({tracer}));
and finally, I create my tracer with code that looks like this
const createTracer = (localServiceName) => {
const tracer = new Tracer({
ctxImpl: new CLSContext('zipkin'),
recorder: new BatchRecorder({
logger: new HttpLogger({
endpoint: 'http://localhost:9411/api/v2/spans',
jsonEncoder: JSON_V2
})
}),
localServiceName: localServiceName // name of this application
});
return tracer;
}
You can see the above code in context in the following github repository.
I've done all this by cargo-culting the code samples from the zipkin github repositories, and I don't know enough about zipkin's implementation to diagnose this further.
How to I get zipkin to see the service-main
-> service-hello
-> service-goodbye
call chain as a single trace?