Observability, have you ever heard about it? Use this concept in your .NET Core applications — Part 1

Fernando Mendes
3 min readJun 9, 2020

As micro-services development model grows, the need to understand precisely how to observe them grows accordingly. Understanding how and why problems can occur is something very important because we know that problems can happen and will happen.

Given a basic example, how do we know that a sales micro-service sent a request to a stock micro-service? Surely, the expected result is that he will debit the stock after the sale, right?

What if something unexpected happen, how do you what happened during this transaction?

This is a basic example for sure, but it can be even more complex, with a mix of different Technologies and distributed systems. Working with Docker and Kubernetes for example, will make the infrastructure more abstract, making it also more complicated to understand what is being executed.

In this type of solution, failure is inevitable, failures can always occur, and having something where provides us with conditions to identify where it failed, and why it failed, is extremely important for the health and evolution of your project.

Therefore, I will talk a little about Observability, a concept that allows us to observe characteristics, attributes of the components involved, which necessarily need to be exposed to understand its operation.

An important point to say is that Observability is totally different from Monitoring, as it is unlikely that only monitoring CPU, memory, disk space, etc., will be possible to ascertain the root cause of the problem.

Observability can be defined in 3 basic elements:
Tracing, Logging e Metrics

Below find some information about each one of them:

Tracing

Ability to track the complete route of a request. In distributed systems, it serves to be able to understand the flow of requests, visualize the services that were executed and the time it took, this is totally important to understand where the problem may be.

Logging

Capturing and storing logs is something we use to identify and resolve problems. It is very effective to understand the flow of the application. But in complex systems, many interdependencies make it difficult to understand when problems occur, just by analyzing them in isolation.

Metrics

Metrics are a numerical representation of the state of systems. They are fundamental to understand the behavior of systems. For complex systems, the importance of having metrics is the creation of alerts.

Sending alerts has always been an important practice to understand what we can evolve in our system, knowing where the alert comes from, we can be more assertive in solving a problem

Tracing, Logging and Metrics together are denominated Observability

Knowing these concepts that we learned above, we will create a scenario where we will put Observability into practice in a complex system with micro services.

There are tools that help us to obtain this Observability, for our practical example, we will use Elastic APM (Application Performance Monitoring), where we will orchestrate our micro-services to be observed and show us the necessary information, about each request that we will perform in API.

For example:

• Understand where the service is spending time on and why it stops working in case of failure

• See how services interact with each other and view bottlenecks

• Discover bottlenecks and performance errors in advance to correct them

• Increase the productivity of the development team

• Monitor the end user experience in the browser

In the second part of our article, we will implement the practical example of how to use Elastic APM.

Here is the part 2 of this article.

--

--

Fernando Mendes

Software Architect .NET C# | Microsoft MVP 🏆🏆 | Co-Founder community JunDevelopers