官术网_书友最值得收藏!

Adding production-ready support

We've created a Spring web app with minimal code and released it to production. This is the perfect time to introduce production-grade support features.

There are some questions that often arise in production, and these are as follows:

  • What do we do when the system administrator wants to configure his or her monitoring software to ping our app to see if it's up?
  • What happens when our manager wants to know the metrics of people hitting our app?
  • What are we going to do when the ops center supervisor calls us at 2:00 a.m. and we have to figure out what went wrong?

The last feature we are going to introduce in this chapter is Spring Boot's Actuator module. This module provides some super slick Ops-oriented features that are incredibly valuable in a production environment.

We start by adding this dependency to our build.gradle as follows:

    compile('org.springframework.boot:spring-boot-starter-actuator') 

When you run this version of our app, the same business functionality is available that we saw earlier, but there are additional HTTP endpoints; these are listed in the following table:

Endpoints, by default, are disabled. We have to opt in. This is accomplished by setting endpoints.{endpoint}.enabled=true inside src/main/resources/application.properties, like this:

endpoints.health.enabled=true

This line added to application.properties mentions the endpoint, health, and enables it. If we restart the application, we can ping for its health, as shown in the next section.

主站蜘蛛池模板: 灯塔市| 普宁市| 临武县| 醴陵市| 无锡市| 阿尔山市| 安新县| 西林县| 盖州市| 柳江县| 枣强县| 汝城县| 峨边| 夏津县| 龙胜| 云霄县| 武清区| 上饶市| 溧水县| 聊城市| 罗定市| 万山特区| 胶南市| 镇远县| 丰台区| 广饶县| 芦溪县| 安丘市| 邓州市| 思南县| 思茅市| 奎屯市| 顺义区| 梨树县| 绥中县| 平罗县| 马尔康县| 涟源市| 东阳市| 三河市| 隆尧县|