Category: Spring Boot
-
Counting Method Invocations Using @Before Advice with Spring AOP and Micrometer
In this tutorial, you’ll learn how to use Spring AOP with Micrometer to: Prerequisites Make sure your Spring Boot project includes these dependencies: You should also have a controller method that you want to observe. For this example, we’ll use a method called fetchQuestions() in QuizController. Step 1: Create or Update the Aspect Class If…
-
Monitoring Method Execution Time in Spring Boot with @Timed and AOP
Why @Timed? Injecting metric logic directly into controllers (or services) introduces code scattering — business logic mixed with monitoring logic. To solve this: This brings us cleaner, more maintainable code. Step 1: Add Dependencies First, add the necessary dependencies to your pom.xml. Make sure you’re using Spring Boot 2.7.x or higher. Step 2: Enable the…
-
Spring Boot Actuator Tutorial: Introduction to Custom Metrics
What Are Metrics? Metrics are numerical measurements that represent the behavior or state of your application over time. They provide insight into everything from response times and memory usage to custom business metrics such as the number of purchases or API errors. Spring Boot Actuator includes built-in metrics and also allows us to create custom…
-
Spring Boot Actuator: Creating a Custom Health Indicator
Why Custom Health Indicators? Spring Boot provides several built-in health checks (e.g., diskSpace, db, ping), but what if: This is where custom health indicators come into play. How to Create a Custom Health Indicator? You can create a custom health indicator by doing one of the following: Option 1: Implement HealthIndicator Interface Option 2: Extend…
-
Setting Up Prometheus to Monitor Spring Boot Metrics
What Is Prometheus? Prometheus is an open-source monitoring system and time-series database. It performs two main tasks: Prometheus is an open-source monitoring system and time-series database. It performs two main tasks: Additionally, Prometheus can: How Prometheus Works with Spring Boot and Micrometer Here’s the basic flow: Prometheus Configuration (prometheus.yml) To tell Prometheus where and how…
-
Integrating Spring Boot Actuator and Micrometer with Prometheus
Why Send Metrics to External Systems? While Micrometer captures and exposes metrics, those metrics are in-memory inside your application. Some popular external systems include: Overview of the Integration Flow Here’s the overall idea: How to Expose Metrics to Prometheus in Spring Boot Spring Boot makes this process very simple. You don’t need to manually write…
-
Monitoring Spring Boot Applications with Spring Boot Actuator and Micrometer – an Introduction
What is Spring Boot Actuator? Spring Boot Actuator is a project designed to help you monitor and manage your Spring Boot application in production.With Actuator, you can get valuable insights and operational information about your application without writing any additional code or manually implementing any monitoring classes. By simply adding Actuator to your Spring Boot…
-
Monitoring and Observability in Spring Applications
What Are Monitoring and Observability? In the software world, “monitoring” and “observability” are terms that are often mistakenly used as if they mean the same thing.While they are closely related, they are not identical, and each serves a specific purpose in building reliable systems. Monitoring Monitoring refers to the act of collecting, analyzing, processing, and…
-
Internationalization (i18n) in Spring Boot
Internationalization (i18n) is the process of designing applications that can be adapted to different languages and regions without requiring code changes. In Spring Boot, this is typically achieved using MessageSource to manage locale-specific messages and configuring locale resolvers. 1. Setting Up MessageSource Bean Spring Boot automatically loads messages from property files in the src/main/resources directory.…
-
RestClient introduced in Spring Boot 3.2
The RestClient is a synchronous HTTP client that offers a modern, fluent API. It offers an abstraction over HTTP libraries that allows for convenient conversion from a Java object to an HTTP request, and the creation of objects from an HTTP response. Creating a RestClient The RestClient is created using one of the static create methods. You can also use builder() to get a…