Skip to content

Commit 8b45e6c

Browse files
committed
Allow soft-rollout with crashtracking auto-config only if ddprof-java is enabled
1 parent 239552e commit 8b45e6c

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

dd-java-agent/agent-bootstrap/src/main/java/datadog/trace/bootstrap/Agent.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import datadog.trace.api.profiling.ProfilingEnablement;
4141
import datadog.trace.api.scopemanager.ScopeListener;
4242
import datadog.trace.bootstrap.benchmark.StaticEventLogger;
43-
import datadog.trace.bootstrap.config.provider.ConfigProvider;
4443
import datadog.trace.bootstrap.config.provider.StableConfigSource;
4544
import datadog.trace.bootstrap.instrumentation.api.AgentTracer;
4645
import datadog.trace.bootstrap.instrumentation.api.AgentTracer.TracerAPI;
@@ -1052,10 +1051,15 @@ private static void initializeCrashTrackingDefault() {
10521051
}
10531052

10541053
private static boolean isCrashTrackingAutoconfigEnabled() {
1055-
return !ConfigProvider.getInstance()
1056-
.getBoolean(
1057-
CrashTrackingConfig.CRASH_TRACKING_DISABLE_AUTOCONFIG,
1058-
CrashTrackingConfig.CRASH_TRACKING_DISABLE_AUTOCONFIG_DEFAULT);
1054+
String enabledVal = ddGetProperty("dd." + CrashTrackingConfig.CRASH_TRACKING_ENABLE_AUTOCONFIG);
1055+
boolean enabled = CrashTrackingConfig.CRASH_TRACKING_ENABLE_AUTOCONFIG_DEFAULT;
1056+
if (enabledVal != null) {
1057+
enabled = Boolean.parseBoolean(enabledVal);
1058+
} else {
1059+
// If the property is not set, then we check if profiling is enabled
1060+
enabled = profilingEnabled;
1061+
}
1062+
return enabled;
10591063
}
10601064

10611065
private static void initializeCrashTracking(boolean delayed, boolean checkNative) {
@@ -1067,7 +1071,7 @@ private static void initializeCrashTracking(boolean delayed, boolean checkNative
10671071
try {
10681072
Class<?> clz = AGENT_CLASSLOADER.loadClass("datadog.crashtracking.Initializer");
10691073
// first try to use the JVMAccess using the native library; unless `checkNative` is false
1070-
boolean rslt =
1074+
Boolean rslt =
10711075
checkNative && (boolean) clz.getMethod("initialize", boolean.class).invoke(null, false);
10721076
if (!rslt) {
10731077
if (delayed) {
@@ -1078,9 +1082,12 @@ private static void initializeCrashTracking(boolean delayed, boolean checkNative
10781082
// delayed initialization, so we need to reschedule it and mark as delayed but do not
10791083
// re-check the native library
10801084
CRASHTRACKER_INIT_AFTER_JMX = Agent::initializeDelayedCrashTrackingOnlyJmx;
1085+
rslt = null; // we will initialize it later
10811086
}
10821087
}
1083-
if (rslt) {
1088+
if (rslt == null) {
1089+
log.debug("Crashtracking initialization delayed until JMX is available");
1090+
} else if (rslt) {
10841091
log.debug("Crashtracking initialized");
10851092
} else {
10861093
log.debug(

dd-trace-api/src/main/java/datadog/trace/api/config/CrashTrackingConfig.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ public final class CrashTrackingConfig {
2727
public static final String CRASH_TRACKING_START_EARLY = "crashtracking.debug.start-force-first";
2828
public static final boolean CRASH_TRACKING_START_EARLY_DEFAULT = false;
2929

30-
public static final String CRASH_TRACKING_DISABLE_AUTOCONFIG =
31-
"crashtracking.debug.autoconfig.disable";
32-
public static final boolean CRASH_TRACKING_DISABLE_AUTOCONFIG_DEFAULT = false;
30+
public static final String CRASH_TRACKING_ENABLE_AUTOCONFIG =
31+
"crashtracking.debug.autoconfig.enable";
32+
public static final boolean CRASH_TRACKING_ENABLE_AUTOCONFIG_DEFAULT = false;
3333

3434
private CrashTrackingConfig() {}
3535
}

0 commit comments

Comments
 (0)