#MicroservicesMonitoring
Explore tagged Tumblr posts
inextures · 2 years ago
Text
Jaeger Integration with Spring Cloud
Tumblr media
In today’s complex landscape of highly distributed microservices, monitoring, and tracing are essential tools for understanding application performance and effectively diagnosing issues. Distributed tracing allows us to track requests as they traverse multiple services, providing valuable insights into potential bottlenecks and latency problems. In this blog post, we will explore the process of setting up distributed tracing in a Spring Boot application, utilizing OpenTelemetry and Jaeger.
Understanding Distributed Tracing
Distributed tracing is a technique that helps developers and operators track requests as they move across various microservices or components of an application. It provides end-to-end visibility into the path a request takes and the time it spends in each service. With this information, you can:
Identify bottlenecks: Find out which parts of your application are causing delays or performance issues.
Optimize performance: Analyze the trace data to identify opportunities for optimizing the performance of your application.
Troubleshoot errors: Quickly pinpoint the source of errors or exceptions in your system, making debugging much easier.
Introducing OpenTelemetry and Jaeger
OpenTelemetry (OTel) is indeed an open-source project that offers a set of APIs, libraries, agents, and instrumentation to help you gain observability into your applications by collecting distributed traces, metrics, and logs. OpenTelemetry is designed to be vendor-neutral and can integrate with a range of tracing systems.
Jaeger is a popular open-source distributed tracing system that can act as a backend for collecting, storing, and visualizing trace data generated by applications instrumented with OpenTelemetry.
Together, OpenTelemetry and Jaeger can be used to collect, analyze, and visualize observability data from distributed systems, providing insights into system performance and helping to troubleshoot issues.
Setting Up OpenTelemetry and Jaeger in Spring Boot
Creating an application
Let’s go to https://start.spring.io and create an application with the following dependencies.
Spring Web (required to create REST endpoints)
Spring Boot Actuator
The traces will be collected using the micrometer collector in the actuator dependence and exported using the OpenTelemetry requirement.
This would necessitate the addition of the following dependencies.
Tumblr media
The Spring Boot parent will handle the dependency versions.
Following that, we will develop two applications.
To export the spans to Jaeger, we must first develop a span exporter bean, as seen below.
Tumblr media
In addition, we will define the Jaeger URL where trace data will be recorded in the properties file.
Service1
Tumblr media
Service 2
Tumblr media
Here, we set the probability of selecting the tracing to 1, which means that every trace and span is reported to Jaeger.
We will also provide a special logging format so that the spans and traces may be seen in the application logs.
Tumblr media
Will also configure bean for RestTemplate
Service-2
in the Controller class
Tumblr media
The idea is to call service2 /hello api from service1 /hello api by using RestTemplate.
Starting Jaeger with Docker
To start Jaeger, we have the following docker cmd.
Tumblr media
For Jaeger to support the OpenTelemetry input format, we need to set the COLLECTOR_OTLP_ENABLED to true
With this, will start the applications.
Now, let’s visualize the traces in Jaeger UI.
To access the Jaeger UI, open the following URL.
Originally published by: Jaeger Integration with Spring Cloud
0 notes