提交 eca20c91 编写于 作者: wu-sheng's avatar wu-sheng

Add process No in register info.

上级 45cbf8b5
......@@ -45,7 +45,8 @@ message ApplicationInstanceHeartbeat {
message OSInfo {
string osName = 1;
string hostname = 2;
repeated string ipv4s = 3;
int32 processNo = 3;
repeated string ipv4s = 4;
}
//discovery service for ServiceName by Network address or application code
......
package org.skywalking.apm.agent.core.os;
import java.lang.management.ManagementFactory;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
......@@ -17,6 +18,7 @@ public class OSUtil {
private static volatile String OS_NAME;
private static volatile String HOST_NAME;
private static volatile List<String> IPV4_LIST;
private static volatile int PROCESS_NO = 0;
public static String getOsName() {
if (OS_NAME == null) {
......@@ -63,6 +65,17 @@ public class OSUtil {
return IPV4_LIST;
}
public static int getProcessNo() {
if (PROCESS_NO == 0) {
try {
PROCESS_NO = Integer.parseInt(ManagementFactory.getRuntimeMXBean().getName().split("@")[0]);
} catch (Exception e) {
PROCESS_NO = -1;
}
}
return PROCESS_NO;
}
public static OSInfo buildOSInfo() {
OSInfo.Builder builder = OSInfo.newBuilder();
String osName = getOsName();
......@@ -77,6 +90,7 @@ public class OSUtil {
if (allIPV4.size() > 0) {
builder.addAllIpv4S(allIPV4);
}
builder.setProcessNo(getProcessNo());
return builder.build();
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册