From 268c5502ed358c9653e45492479e6ced91ec9239 Mon Sep 17 00:00:00 2001 From: Eric Zhao Date: Tue, 23 Apr 2019 14:53:53 +0800 Subject: [PATCH] Update transport module to carry appName in heartbeat message Signed-off-by: Eric Zhao --- .../csp/sentinel/transport/heartbeat/HttpHeartbeatSender.java | 2 ++ .../csp/sentinel/transport/heartbeat/HeartbeatMessage.java | 3 +++ 2 files changed, 5 insertions(+) diff --git a/sentinel-transport/sentinel-transport-netty-http/src/main/java/com/alibaba/csp/sentinel/transport/heartbeat/HttpHeartbeatSender.java b/sentinel-transport/sentinel-transport-netty-http/src/main/java/com/alibaba/csp/sentinel/transport/heartbeat/HttpHeartbeatSender.java index b528a4a4..e150f266 100755 --- a/sentinel-transport/sentinel-transport-netty-http/src/main/java/com/alibaba/csp/sentinel/transport/heartbeat/HttpHeartbeatSender.java +++ b/sentinel-transport/sentinel-transport-netty-http/src/main/java/com/alibaba/csp/sentinel/transport/heartbeat/HttpHeartbeatSender.java @@ -19,6 +19,7 @@ import java.util.ArrayList; import java.util.List; import com.alibaba.csp.sentinel.Constants; +import com.alibaba.csp.sentinel.config.SentinelConfig; import com.alibaba.csp.sentinel.spi.SpiOrder; import com.alibaba.csp.sentinel.transport.config.TransportConfig; import com.alibaba.csp.sentinel.log.RecordLog; @@ -110,6 +111,7 @@ public class HttpHeartbeatSender implements HeartbeatSender { uriBuilder.setScheme("http").setHost(consoleHost).setPort(consolePort) .setPath("/registry/machine") .setParameter("app", AppNameUtil.getAppName()) + .setParameter("app_type", String.valueOf(SentinelConfig.getAppType())) .setParameter("v", Constants.SENTINEL_VERSION) .setParameter("version", String.valueOf(System.currentTimeMillis())) .setParameter("hostname", HostNameUtil.getHostName()) diff --git a/sentinel-transport/sentinel-transport-simple-http/src/main/java/com/alibaba/csp/sentinel/transport/heartbeat/HeartbeatMessage.java b/sentinel-transport/sentinel-transport-simple-http/src/main/java/com/alibaba/csp/sentinel/transport/heartbeat/HeartbeatMessage.java index 5695632c..9a981238 100755 --- a/sentinel-transport/sentinel-transport-simple-http/src/main/java/com/alibaba/csp/sentinel/transport/heartbeat/HeartbeatMessage.java +++ b/sentinel-transport/sentinel-transport-simple-http/src/main/java/com/alibaba/csp/sentinel/transport/heartbeat/HeartbeatMessage.java @@ -19,6 +19,7 @@ import java.util.HashMap; import java.util.Map; import com.alibaba.csp.sentinel.Constants; +import com.alibaba.csp.sentinel.config.SentinelConfig; import com.alibaba.csp.sentinel.transport.config.TransportConfig; import com.alibaba.csp.sentinel.util.AppNameUtil; import com.alibaba.csp.sentinel.util.HostNameUtil; @@ -38,6 +39,8 @@ public class HeartbeatMessage { message.put("hostname", HostNameUtil.getHostName()); message.put("ip", TransportConfig.getHeartbeatClientIp()); message.put("app", AppNameUtil.getAppName()); + // Put application type (since 1.6.0). + message.put("app_type", String.valueOf(SentinelConfig.getAppType())); message.put("port", String.valueOf(TransportConfig.getPort())); }