appmetrics-zipkin is now live but what is it and why should you use it ?

Put simply, appmetrics-zipkin will automatically provide integration with the Zipkin distributed tracing system by adding just a single line of code to your Node.js application. In turn, this will trace all inbound and outbound http/https requests through the system providing automatic scan correlation without the need for any additional code changes.

What is Zipkin ?

Zipkin provides a service that gathers timing data needed to troubleshoot latency problems in microservice archtiectures. To make use of this service, applications require modification to add the necessary instrumentation so that they can report timing data to Zipkin. This instrumentation typically comes in two forms.

  • Add tracing to inbound requests
  • Add tracing to outbound requests

In this context, a trace is simply a way of being able to tell the story of a transaction or workflow as it travels through a system. It will record how long the transaction spends in each particular component of that system as well as including any additional workflows that are created. Each request is given a unique trace ID and its this ID that allows Zipkin to track the request.

This gives a very straightforward view (via the Zipkin UI) of the journey a transaction has taken through the system.

Zipkin UI

appmetrics-zipkin has combined the tracing of inbound and the tracing of outbound into a single, easy to use, module. This removes the need that other implementations have of requiring the user to keep track of the trace ID from incoming events and then having to add them to outgoing events if they are related.

The video below shows the transaction flow of an incoming http request that triggers and outbound request and at what points in the flow the Zipkin server is sent data.


var appzip = require('appmetrics-zipkin');   // This is the single line code change !!
var express = require('express');
var app = express();
app.get('/api', (req, res) => res.send(new Date().toString()));
app.listen(9000, () => {
  console.log('Backend listening on port 9000!');

appmetrics-zipkin with zero code changes

It is possible to use appmetrics-zipkin with your application without actually making any code changes by launching your application as follows.

node -r appmetrics-zipkin myApp.js


Note: require(‘appmetrics-zipkin’) should be included before requiring other packages to ensure those packages are correctly instrumented.

4 comments on"Add Zipkin trace support to your Node.js application with one line of code"

  1. Adrian Cole October 28, 2017

    I don’t think this has anything to do with OpenTracing, right? The library mentioned appears to be using zipkin-js. Might want to change the title I think.

  2. Brian Devins October 30, 2017

    I think the title of your post might cause some confusion, “open tracing” may sound too similar to OpenTracing for some people. Otherwise great post and a new library to add to the toolbox!

  3. […] Add Zipkin trace support to your Node.js application with one line of code […]

Join The Discussion

Your email address will not be published. Required fields are marked *