diff --git a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/alarm/DingSendMessageHandler.java b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/alarm/DingSendMessageHandler.java
index 18f8c756..e5fbae8c 100644
--- a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/alarm/DingSendMessageHandler.java
+++ b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/alarm/DingSendMessageHandler.java
@@ -69,6 +69,7 @@ public class DingSendMessageHandler implements SendMessageHandler {
"[警报] %s - 动态线程池运行告警 \n\n" +
" --- \n\n " +
"线程池ID:%s \n\n " +
+ "应用名称:%s \n\n " +
"应用实例:%s \n\n " +
" --- \n\n " +
"核心线程数:%d \n\n " +
@@ -94,8 +95,10 @@ public class DingSendMessageHandler implements SendMessageHandler {
active.toUpperCase(),
// 线程池ID
pool.getThreadPoolId(),
- // 节点信息
- instanceInfo.getIpApplicationName(),
+ // 应用名称
+ instanceInfo.getAppName(),
+ // 实例信息
+ instanceInfo.getIdentify(),
// 核心线程数
pool.getCorePoolSize(),
// 最大线程数
@@ -150,6 +153,7 @@ public class DingSendMessageHandler implements SendMessageHandler {
"[通知] %s - 动态线程池参数变更 \n\n" +
" --- \n\n " +
"线程池ID:%s \n\n " +
+ "应用名称:%s \n\n " +
"应用实例:%s \n\n " +
" --- \n\n " +
"核心线程数:%s \n\n " +
@@ -170,8 +174,10 @@ public class DingSendMessageHandler implements SendMessageHandler {
active.toUpperCase(),
// 线程池名称
threadPoolId,
- // 节点信息
- instanceInfo.getIpApplicationName(),
+ // 应用名称
+ instanceInfo.getAppName(),
+ // 实例信息
+ instanceInfo.getIdentify(),
// 核心线程数
customPool.getCorePoolSize() + " ➲ " + parameter.getCoreSize(),
// 最大线程数
diff --git a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/config/DiscoveryConfig.java b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/config/DiscoveryConfig.java
index 55eab5ca..43c8223f 100644
--- a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/config/DiscoveryConfig.java
+++ b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/config/DiscoveryConfig.java
@@ -35,8 +35,8 @@ public class DiscoveryConfig {
@SneakyThrows
public InstanceInfo instanceConfig() {
InstanceInfo instanceInfo = new InstanceInfo();
- instanceInfo.setInstanceId(getDefaultInstanceId(environment))
- .setIpApplicationName(getIpApplicationName(environment))
+ instanceInfo.setInstanceId(getDefaultInstanceId(environment, inetUtils))
+ .setIpApplicationName(getIpApplicationName(environment, inetUtils))
.setHostName(InetAddress.getLocalHost().getHostAddress())
.setGroupKey(properties.getItemId() + "+" + properties.getNamespace())
.setAppName(environment.getProperty("spring.application.name"))
diff --git a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/CloudCommonIdUtil.java b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/CloudCommonIdUtil.java
index 2b7b900f..4ec3a68d 100644
--- a/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/CloudCommonIdUtil.java
+++ b/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/starter/toolkit/CloudCommonIdUtil.java
@@ -1,10 +1,9 @@
package cn.hippo4j.starter.toolkit;
+import cn.hippo4j.starter.toolkit.inet.InetUtils;
import lombok.SneakyThrows;
import org.springframework.core.env.PropertyResolver;
-import java.net.InetAddress;
-
/**
* Cloud common id util.
*
@@ -16,16 +15,15 @@ public class CloudCommonIdUtil {
private static final String SEPARATOR = ":";
@SneakyThrows
- public static String getDefaultInstanceId(PropertyResolver resolver) {
- String namePart = getIpApplicationName(resolver);
+ public static String getDefaultInstanceId(PropertyResolver resolver, InetUtils inetUtils) {
+ String namePart = getIpApplicationName(resolver, inetUtils);
String indexPart = resolver.getProperty("spring.application.instance_id", resolver.getProperty("server.port"));
return combineParts(namePart, SEPARATOR, indexPart);
}
@SneakyThrows
- public static String getIpApplicationName(PropertyResolver resolver) {
- InetAddress host = InetAddress.getLocalHost();
- String hostname = host.getHostAddress();
+ public static String getIpApplicationName(PropertyResolver resolver, InetUtils inetUtils) {
+ String hostname = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress();
String appName = resolver.getProperty("spring.application.name");
return combineParts(hostname, SEPARATOR, appName);
}