Skip to content

Commit 04865d3

Browse files
mccullsdevflow.devflow-routing-intake
andauthored
Disable stable session id propagation until after tracer is registered (#11448)
Disable stable session id propagation until after tracer is registered This avoids a potential reentrant situation when tracer debug is enabled: 1. The full `Config` is logged during startup in its constructor 2. This includes any lazy config fields, such as the `hostname` 3. If the host is not available in the environment/host-files then `Config` calls the `hostname` command using `Runtime.exec(...)` 4. The `Runtime.exec(...)` call is intercepted by the process advice 5. The process advice calls `Config.get()` to get the stable session id 6. `Config.get()` returns `null` as the config is still being built The resulting NPE is caught before it escapes to the application, but it still results in log-spam that could confuse investigations. Co-authored-by: devflow.devflow-routing-intake <devflow.devflow-routing-intake@kubernetes.us1.ddbuild.io>
1 parent 59889c2 commit 04865d3

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

  • dd-java-agent/instrumentation/java/java-lang/java-lang-1.8/src/main/java/datadog/trace/instrumentation/java/lang

dd-java-agent/instrumentation/java/java-lang/java-lang-1.8/src/main/java/datadog/trace/instrumentation/java/lang/ProcessImplStartAdvice.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,17 @@ class ProcessImplStartAdvice {
1212
public static AgentSpan beforeStart(
1313
@Advice.Argument(0) final String[] command,
1414
@Advice.Argument(1) final Map<String, String> environment) {
15+
16+
if (!AgentTracer.isRegistered()) {
17+
return null;
18+
}
19+
1520
String rootSessionId = Config.get().getRootSessionId();
1621
if (rootSessionId != null && environment != null) {
1722
environment.put("_DD_ROOT_JAVA_SESSION_ID", rootSessionId);
1823
}
1924

20-
if (!ProcessImplInstrumentationHelpers.ONLINE) {
21-
return null;
22-
}
23-
24-
if (command.length == 0 || !AgentTracer.isRegistered()) {
25+
if (!ProcessImplInstrumentationHelpers.ONLINE || command.length == 0) {
2526
return null;
2627
}
2728

0 commit comments

Comments
 (0)