Exercise 2 – the first trace
Now that we are familiar with the sample application, let's add some very basic instrumentation to it to create a trace for each HTTP request that it handles. We will do it in three steps:
- Create a tracer instance
- Start a span in the HTTP handler function
- Annotate the span with additional details in a few places in the code
Step 1 – create a tracer instance
As mentioned, OpenTracing is just an API, so we need to instantiate a concrete implementation of the tracer. We will be using the Jaeger tracer as an example, but the function that creates the tracer will be the only place in the whole program that is Jaeger-specific. It can be easily replaced with any other OpenTracing-compatible tracer, such as Zipkin or tracers from ...