修改钉钉通知消息体, 增加应用实例标识.

pull/10/head
chen.ma 3 years ago
parent a65df935ea
commit a84e1b4fa9

@ -69,6 +69,7 @@ public class DingSendMessageHandler implements SendMessageHandler {
"<font color='#FF0000'>[警报] </font>%s - 动态线程池运行告警 \n\n" +
" --- \n\n " +
"<font color='#708090' size=2>线程池ID%s</font> \n\n " +
"<font color='#708090' size=2>应用名称:%s</font> \n\n " +
"<font color='#778899' size=2>应用实例:%s</font> \n\n " +
" --- \n\n " +
"<font color='#708090' size=2>核心线程数:%d</font> \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 {
"<font color='#2a9d8f'>[通知] </font>%s - 动态线程池参数变更 \n\n" +
" --- \n\n " +
"<font color='#708090' size=2>线程池ID%s</font> \n\n " +
"<font color='#708090' size=2>应用名称:%s</font> \n\n " +
"<font color='#778899' size=2>应用实例:%s</font> \n\n " +
" --- \n\n " +
"<font color='#708090' size=2>核心线程数:%s</font> \n\n " +
@ -170,8 +174,10 @@ public class DingSendMessageHandler implements SendMessageHandler {
active.toUpperCase(),
// 线程池名称
threadPoolId,
// 节点信息
instanceInfo.getIpApplicationName(),
// 应用名称
instanceInfo.getAppName(),
// 实例信息
instanceInfo.getIdentify(),
// 核心线程数
customPool.getCorePoolSize() + " ➲ " + parameter.getCoreSize(),
// 最大线程数

@ -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"))

@ -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);
}

Loading…
Cancel
Save