In this chapter, you’ll start to learn how ASP.NET helps us tackle some important cross-cutting concerns: monitoring, logging, and tracing. All three are needed across all microservices, and they play an important role in making a microservice system operations friendly. Once your system is in production, you need to know whether all your microservices are up, which is why you need to monitor them. In addition, as discussed in chapter 7, you need good logging to be able to diagnose the system.
Here, you’ll configure middleware in the context of one microservice. Then, in chapter 11, you’ll take that configuration and put it into NuGet packages, ready to be reused easily across all your microservices.
When you deploy any server-side system into production, you need to be able to check the health of the system. You want to know whether it is up, whether it’s experiencing failures or errors, and whether it’s performing as well as it usually does. This is true of any system. With a traditional monolithic system, you’d most likely set up some monitoring and add logging to the system, as shown in figure 9.1. Logging is often done many places in the code base—where there’s something important to log—and the messages are often stored in a database.