diff --git a/src/main/java/com/nhn/pinpoint/profiler/AgentInformation.java b/src/main/java/com/nhn/pinpoint/profiler/AgentInformation.java index b37140a6c..5890812b2 100644 --- a/src/main/java/com/nhn/pinpoint/profiler/AgentInformation.java +++ b/src/main/java/com/nhn/pinpoint/profiler/AgentInformation.java @@ -10,8 +10,9 @@ public class AgentInformation { private final int pid; private final String machineName; private final short serverType; + private final String version; - public AgentInformation(String agentId, String applicationName, long startTime, int pid, String machineName, short serverType) { + public AgentInformation(String agentId, String applicationName, long startTime, int pid, String machineName, short serverType, String version) { if (agentId == null) { throw new NullPointerException("agentId must not be null"); } @@ -21,12 +22,16 @@ public class AgentInformation { if (machineName == null) { throw new NullPointerException("machineName must not be null"); } + if (version == null) { + throw new NullPointerException("version must not be null"); + } this.agentId = agentId; this.applicationName = applicationName; this.startTime = startTime; this.pid = pid; this.machineName = machineName; this.serverType = serverType; + this.version = version; } @@ -55,6 +60,10 @@ public class AgentInformation { return serverType; } + public String getVersion() { + return version; + } + @Override public String toString() { final StringBuilder sb = new StringBuilder("AgentInformation{"); @@ -64,6 +73,7 @@ public class AgentInformation { sb.append(", pid=").append(pid); sb.append(", machineName='").append(machineName).append('\''); sb.append(", serverType=").append(serverType); + sb.append(", version='").append(version).append('\''); sb.append('}'); return sb.toString(); } diff --git a/src/main/java/com/nhn/pinpoint/profiler/DefaultAgent.java b/src/main/java/com/nhn/pinpoint/profiler/DefaultAgent.java index 522a8d39e..74663d6ef 100644 --- a/src/main/java/com/nhn/pinpoint/profiler/DefaultAgent.java +++ b/src/main/java/com/nhn/pinpoint/profiler/DefaultAgent.java @@ -3,6 +3,7 @@ package com.nhn.pinpoint.profiler; import com.nhn.pinpoint.ProductInfo; import com.nhn.pinpoint.common.PinpointConstants; import com.nhn.pinpoint.common.ServiceType; +import com.nhn.pinpoint.common.Version; import com.nhn.pinpoint.common.util.BytesUtils; import com.nhn.pinpoint.exception.PinpointException; import com.nhn.pinpoint.profiler.context.*; @@ -129,7 +130,7 @@ public class DefaultAgent implements Agent { final String applicationName = getId("pinpoint.applicationName", "UnknownApplicationName", PinpointConstants.APPLICATION_NAME_MAX_LEN); final long startTime = RuntimeMXBeanUtils.getVmStartTime(); final int pid = RuntimeMXBeanUtils.getPid(); - return new AgentInformation(agentId, applicationName, startTime, pid, machineName, serverType.getCode()); + return new AgentInformation(agentId, applicationName, startTime, pid, machineName, serverType.getCode(), Version.VERSION); } diff --git a/src/test/java/com/nhn/pinpoint/profiler/context/DefaultTraceTest.java b/src/test/java/com/nhn/pinpoint/profiler/context/DefaultTraceTest.java index 256884e62..28a0de52a 100644 --- a/src/test/java/com/nhn/pinpoint/profiler/context/DefaultTraceTest.java +++ b/src/test/java/com/nhn/pinpoint/profiler/context/DefaultTraceTest.java @@ -1,6 +1,7 @@ package com.nhn.pinpoint.profiler.context; import com.nhn.pinpoint.common.ServiceType; +import com.nhn.pinpoint.common.Version; import com.nhn.pinpoint.profiler.AgentInformation; import com.nhn.pinpoint.profiler.logging.Slf4jLoggerBinderInitializer; import com.nhn.pinpoint.profiler.sender.LoggingDataSender; @@ -29,7 +30,7 @@ public class DefaultTraceTest { @Test public void testPushPop() { DefaultTraceContext defaultTraceContext = new DefaultTraceContext(); - defaultTraceContext.setAgentInformation(new AgentInformation("agentId", "applicationName", System.currentTimeMillis(), 10, "test", ServiceType.TOMCAT.getCode())); + defaultTraceContext.setAgentInformation(new AgentInformation("agentId", "applicationName", System.currentTimeMillis(), 10, "test", ServiceType.TOMCAT.getCode(), Version.VERSION)); DefaultTrace trace = new DefaultTrace(defaultTraceContext, "agent", 0, 1); trace.setStorage(new SpanStorage(LoggingDataSender.DEFAULT_LOGGING_DATA_SENDER)); diff --git a/src/test/java/com/nhn/pinpoint/profiler/context/TraceTest.java b/src/test/java/com/nhn/pinpoint/profiler/context/TraceTest.java index 843892687..9f3b67b66 100644 --- a/src/test/java/com/nhn/pinpoint/profiler/context/TraceTest.java +++ b/src/test/java/com/nhn/pinpoint/profiler/context/TraceTest.java @@ -2,6 +2,7 @@ package com.nhn.pinpoint.profiler.context; import com.nhn.pinpoint.common.AnnotationKey; import com.nhn.pinpoint.common.ServiceType; +import com.nhn.pinpoint.common.Version; import com.nhn.pinpoint.profiler.AgentInformation; import com.nhn.pinpoint.profiler.sender.EnhancedDataSender; @@ -56,7 +57,7 @@ public class TraceTest { private DefaultTraceContext getDefaultTraceConetxt() { DefaultTraceContext defaultTraceContext = new DefaultTraceContext(); - defaultTraceContext.setAgentInformation(new AgentInformation("agentId", "applicationName", System.currentTimeMillis(), 10, "test", ServiceType.TOMCAT.getCode())); + defaultTraceContext.setAgentInformation(new AgentInformation("agentId", "applicationName", System.currentTimeMillis(), 10, "test", ServiceType.TOMCAT.getCode(), Version.VERSION)); return defaultTraceContext; }