Search code examples
javaspringspring-bootmicroservicesmetrics

Measuring time between 2 points of various microservices


Example:
We have 2 microservices (A, B) and queue (Q).

A receives request from client, process this request and sends message to Q
B receives message from Q process this message and saving some stuff to database.

I want to measure time between these points (including time when message is waiting on queue):

  • application A is starting to process request
  • application B is ending processing message

There are any ready solution for collecting that metrics? (It would be nice if it was easily integrative with spring-boot)


Solution

  • The easy/fast way: just log the events you are interested in, and make the time difference.

    The professional/right way: integrate a metric system with your spring-boot application. This requires some effort, but the benefits are much bigger.

    Here are the steps:

    • Document about Prometheus, Micrometer, Grafana
    • Follow this step-by-step guide which shows you how to integrate those components and add your own custom metric
    • Add your own metrics and create dashboards (in other words, build your observability setup, because you already got all the components in place)