Tracing is a simple way how to visualize the flow of a request between components. A unique trace ID is generated for every new request. As some component receives the request a new span is assigned for that component and the span is added to the trace. The traces are then sent to jaeger collector. You can find more information about the tracing here.
First, we need to add these dependencies to our pom.xml file.
We also need to change the configuration file (application.yaml) for our application.
Tracing and database queries
First, we need to add a TracingHelper class. This class can create new spans.
Now, we need to add an aspect to our repository. Adding this aspect will cause a new span to be automatically created with every DB query and it will take care of the whole lifecycle of the created span.
Manually created spans
Code can look like this: