Skip to content

Commit e5871d3

Browse files
committed
support dynamic attach
1 parent cb3f0bd commit e5871d3

File tree

1 file changed

+8
-6
lines changed
  • javaagent-bootstrap/src/main/java/io/opentelemetry/javaagent/bootstrap

1 file changed

+8
-6
lines changed

javaagent-bootstrap/src/main/java/io/opentelemetry/javaagent/bootstrap/AgentArgUtil.java

+8-6
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,17 @@ private AgentArgUtil() {}
1515
public static void setSystemProperties(@Nullable String agentArgs) {
1616
boolean debug = false;
1717
if (agentArgs != null && !agentArgs.isEmpty()) {
18-
String[] options = agentArgs.split(";");
19-
for (String option : options) {
18+
for (String option : agentArgs.split(";")) {
2019
String[] keyValue = option.split("=");
2120
if (keyValue.length == 2) {
22-
if (keyValue[0].equals("otel.javaagent.debug")) {
23-
debug = Boolean.parseBoolean(keyValue[1]);
24-
System.setProperty(keyValue[0], keyValue[1]);
21+
String key = keyValue[0];
22+
String value = keyValue[1];
23+
System.setProperty(key, value);
24+
if (key.equals("otel.javaagent.debug")) {
25+
debug = Boolean.parseBoolean(value);
26+
}
2527
if (debug) {
26-
System.out.println("Setting property [" + keyValue[0] + "] = " + keyValue[1]);
28+
System.out.println("Setting property [" + key + "] = " + value);
2729
}
2830
}
2931
}

0 commit comments

Comments
 (0)