The OpenTracing [18] project was created to solve exactly the set of problems that we outlined in the previous section. It provides a standardized, vendor-neutral API that software engineers can use to instrument their code base to enable support for request tracing. Moreover, OpenTracing not only dictates the appropriate encoding for transferring trace contexts across service boundaries, but also provides APIs to facilitate the exchange of tracing context over REST and gRPC transports.
Before we continue, let's spend some time explaining a term that we will be using quite a lot in the following sections. A request trace is comprised of a sequence of spans. A span represents a timed unit of work that executes inside a microservice. In a typical scenario, a new span begins when the service receives a request and ends when the service returns a response.
Furthermore, spans can also be nested. If service A needs to contact downstream services B and C for additional data before it can send back a response, then the spans from B and C can be added as children of A's span. Consequently, a request trace can be thought of as a tree of spans whose root is the service that received the initial request.