Log where all version files are visible
MODIFY
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/TracerInstaller.java
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/TracerInstaller.java
package datadog.trace.agent.tooling;
-import datadog.opentracing.DDTraceOTInfo;
import datadog.opentracing.DDTracer;
-import datadog.trace.api.DDTraceApiInfo;
import io.opentracing.Tracer;
import io.opentracing.util.GlobalTracer;
import lombok.extern.slf4j.Slf4j;
@@ -24,11 +22,7 @@ public class TracerInstaller {
}
public static void logVersionInfo() {
- // version classes log important info
- // in static initializers
- final String s = DDTraceOTInfo.VERSION.toString();
- final String s1 = DDTraceApiInfo.VERSION.toString();
- final String s2 = DDJavaAgentInfo.VERSION.toString();
+ VersionLogger.logAllVersions();
log.debug(GlobalTracer.class.getName() + " loaded on " + GlobalTracer.class.getClassLoader());
log.debug(
AgentInstaller.class.getName() + " loaded on " + AgentInstaller.class.getClassLoader());

ADD
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/VersionLogger.java
+package datadog.trace.agent.tooling;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import lombok.extern.slf4j.Slf4j;
+
+@Slf4j
+public class VersionLogger {
+
+ /** Log version strings for dd-trace-ot, dd-trace-pai, and dd-java-agent */
+ public static void logAllVersions() {
+ log.info(
+ "dd-trace-ot - version: {}",
+ getVersionString(Utils.getAgentClassLoader().getResourceAsStream("dd-trace-ot.version")));
+ log.info(
+ "dd-trace-api - version: {}",
+ getVersionString(Utils.getAgentClassLoader().getResourceAsStream("dd-trace-api.version")));
+ log.info(
+ "dd-java-agent - version: {}",
+ getVersionString(
+ ClassLoader.getSystemClassLoader().getResourceAsStream("dd-java-agent.version")));
+ }
+
+ private static String getVersionString(InputStream stream) {
+ String v;
+ try {
+ final StringBuilder sb = new StringBuilder();
+ final BufferedReader br = new BufferedReader(new InputStreamReader(stream, "UTF-8"));
+ for (int c = br.read(); c != -1; c = br.read()) sb.append((char) c);
+
+ v = sb.toString().trim();
+ } catch (final Exception e) {
+ log.error("failed to read version stream", e);
+ v = "unknown";
+ } finally {
+ try {
+ if (null != stream) {
+ stream.close();
+ }
+ } catch (IOException e) {
+ }
+ }
+ return v;
+ }
+}

Log where all version files are visible