Tracing HTTP Request Latency in Go with OpenTracing

19

In Go 1.7 we have a new package net/http/httptrace that provides a convenient mechanism for observing what happens during an HTTP request. In this article I will show how it can be used in the context of distributed tracing, by using OpenTracing API to instrument a client and a server and visualize the results in Zipkin UI.

First, a bit of an introduction.

What is Distributed Tracing and OpenTracing?

Distributed tracing is a technique for monitoring and profiling systems built on microservices architecture, popularized by such systems as X-Trace,Google’s Dapper and Twitter’s Zipkin. At its foundation is the idea ofdistributed context propagation, which involves associating certain metadata with every request as it enters the system, and propagating that metadata across thread and process boundaries as the request execution fans out to other microservices. If we assign a unique ID to each inbound request and carry it as part of the distributed context, we can then stitch together various profiling data from multiple threads and multiple processes into a single “trace” that represents the execution of the request by our system.

Read more at Yuri Shkuro’s Blog