11 Tracing microservices

 

This chapter covers

  • Using tracing between microservices
  • Viewing traces with the Jaeger UI
  • Injecting a tracer to customize attributes on a span
  • Tracing beyond HTTP

Any form of application observability requires tracing execution paths within a distributed system. With the rise of distributed systems, developers can no longer debug and step through code because they are now dealing with many services. Tracing is the new debugging when dealing with distributed systems. In addition, being able to visualize the bottlenecks in services by observing higher execution times is critical. By no means does this discount the importance of observing metrics, discussed in chapter 10, but it is often necessary to drill deeper into a specific execution path to determine the root of a problem.

In essence, tracing is a key tool in the operations toolbox for observing a running production system. It is the best means of debugging the execution path of a distributed system.

In this chapter, we update the example architecture from chapter 8 to include tracing to highlight the impact of tracing across different communication mechanisms. These include HTTP calls, both into a service and to another service, database interactions, and sending or receiving messages from Apache Kafka.

For a reminder of the services from chapter 8 and how they interact, see figure 11.1.

Figure 11.1 Microservice architecture

11.1 How does tracing work?

11.2 Jaeger

11.2.1 Trace sampling

11.2.2 Setting up the Minikube environment

11.2.3 Installing Jaeger

11.2.4 Microservice tracing with Jaeger

11.3 Tracing specifications

11.3.1 OpenTracing

11.3.2 What is MicroProfile OpenTracing?

11.3.3 OpenTelemetry

11.4 Customizing application tracing

11.4.1 Using @Traced

11.4.2 Injecting a tracer

11.4.3 Tracing database calls

11.4.4 Tracing Kafka messages

Summary