Introduction: Observability with Microprofile

Microservice architecture is an approach that is very compliant with the cloud environment, permitting us the ability to create a cloud native application. With microservice architecture, we promote resilience, fault tolerance and scale. However, this approach has different challenges than monolithic applications.

In a monolithic application, all code and business role is inside one application. With this, all transactions occur inside the same application. However, the microservice architecture breaks the monolithic application into services that are packaged independently and have an independent life. With this, we have several cross cutting concerns that occur in several services. In other words, we have several processes, concerns or logic that act with distributed way. One of these concerns is about monitoring and logging. With this, we have the concept of Observability.

What is Observability?

The concept of Observability is a concept that came from the control theory, that is a math theory.

Formally, a system is said to be observable if, for any possible sequence of state and control vectors (the latter being variables whose values one can choose), the current state (the values of the underlying dynamically evolving variables) can be determined in finite time using only the outputs.


Some developers define Observability in a microservice architecture as the set of metrics, logging and tracing tools, but I think observibility as a more generic concept. Metrics, logging and tracing is only a way to provide observability, but in the future we can use another way.

To me, observibility is the capacity of a system expose precise information about its states with easier and faster way. Differently from monitoring, observability is about the own system. When we say about monitoring, the focal point is the tools that will be used to monitoring the system, but the system can be easy or hard to monitor. When we say about observability, the focal point is the own system, that need to provide this information in a easier and faster way. Monitoring a system with observability is always easy, because the system exposes its information facilitating the monitoring.

Observability with Microprofile

With aim to promote a easy support to observability, the Microprofile has some specs to permit the developer to implement observability in our microservices. The Microprofile has 3 main specs to do that, those specs are:  Microprofile OpenTracing, Microprofile Metrics and Microprofile HealthCheck.

Screenshot from 2019-02-27 16-44-31

Microprofile OpenTracing

Microprofile OpenTracing is a spec that permits us to use distributed tracing using the OpenTracing API to trace  the flow of a request across service. This spec is compatible to Zipkin and compatible to Jaeger , and permits us to use Zipkin or Jaeger to show the information about the distributed tracing. Below we have an example of how to use Microprofile OpenTracing.

public class SubjectEndpoint {



Microprofile Metrics

Microprofile Metrics is a spec that permits us to expose metrics information about our applications. With this, we can expose precise metrics to be consumed with easier and faster ways. Below we have an example of how to use Microprofile Metrics.

public CounterBean() {

Microprofile HealthCheck

Health Check is a spec that permit us expose if the application is up or down in our environment. It works as a boolean response (yes or no) to the question “Is my application still running ok?“. Below we have an example of how to use Microprofile HealthCheck.

public class ApplicationHealthCheck implements HealthCheck {

    public HealthCheckResponse call() {
        return HealthCheckResponse
                .withData("CPUAvailable", Runtime.getRuntime().availableProcessors())
                .withData( "MemoryFree", Runtime.getRuntime().freeMemory())
                .withData("TotalMemory", Runtime.getRuntime().totalMemory())


The Microprofile has been to promote several solutions to microservice challenges, and one of those solutions are the specs to promote observability in our microservices. With this, we can use microprofile with Jaeger, Zipkin, Prometheus and others to promote better observability and monitoring. This article was only a introduction and I will post more details of these specs in the next posts.

If you want to know more about Microprofile access .

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s