Skip to content

Add In-Product Enablement #8461

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.continue.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ instrumentation_modules: &instrumentation_modules "dd-java-agent/instrumentation
debugger_modules: &debugger_modules "dd-java-agent/agent-debugger|dd-java-agent/agent-bootstrap|dd-java-agent/agent-builder|internal-api|communication|dd-trace-core"
profiling_modules: &profiling_modules "dd-java-agent/agent-profiling"

default_system_tests_commit: &default_system_tests_commit 0509dbd094c9cbf15f58db96f62276a0adff7efa
default_system_tests_commit: &default_system_tests_commit 6980534f333b3f7a35d83df2230f00f4e26642f5

parameters:
nightly:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ private enum AgentFeature {
CIVISIBILITY_AGENTLESS(CiVisibilityConfig.CIVISIBILITY_AGENTLESS_ENABLED, false),
USM(UsmConfig.USM_ENABLED, false),
TELEMETRY(GeneralConfig.TELEMETRY_ENABLED, true),
DEBUGGER(DebuggerConfig.DYNAMIC_INSTRUMENTATION_ENABLED, false),
EXCEPTION_DEBUGGING(DebuggerConfig.EXCEPTION_REPLAY_ENABLED, false),
SPAN_ORIGIN(TraceInstrumentationConfig.CODE_ORIGIN_FOR_SPANS_ENABLED, false),
DYNAMIC_INSTRUMENTATION(DebuggerConfig.DYNAMIC_INSTRUMENTATION_ENABLED, false),
EXCEPTION_REPLAY(DebuggerConfig.EXCEPTION_REPLAY_ENABLED, false),
CODE_ORIGIN(TraceInstrumentationConfig.CODE_ORIGIN_FOR_SPANS_ENABLED, false),
DATA_JOBS(GeneralConfig.DATA_JOBS_ENABLED, false),
AGENTLESS_LOG_SUBMISSION(GeneralConfig.AGENTLESS_LOG_SUBMISSION_ENABLED, false);

Expand Down Expand Up @@ -149,9 +149,10 @@ public boolean isEnabledByDefault() {
private static boolean ciVisibilityEnabled = false;
private static boolean usmEnabled = false;
private static boolean telemetryEnabled = true;
private static boolean debuggerEnabled = false;
private static boolean exceptionDebuggingEnabled = false;
private static boolean spanOriginEnabled = false;
private static boolean dynamicInstrumentationEnabled = false;
private static boolean exceptionReplayEnabled = false;
private static boolean codeOriginEnabled = false;
private static boolean distributedDebuggerEnabled = false;
private static boolean agentlessLogSubmissionEnabled = false;

/**
Expand Down Expand Up @@ -261,9 +262,9 @@ public static void start(
|| isFeatureEnabled(AgentFeature.DEPRECATED_REMOTE_CONFIG);
cwsEnabled = isFeatureEnabled(AgentFeature.CWS);
telemetryEnabled = isFeatureEnabled(AgentFeature.TELEMETRY);
debuggerEnabled = isFeatureEnabled(AgentFeature.DEBUGGER);
exceptionDebuggingEnabled = isFeatureEnabled(AgentFeature.EXCEPTION_DEBUGGING);
spanOriginEnabled = isFeatureEnabled(AgentFeature.SPAN_ORIGIN);
dynamicInstrumentationEnabled = isFeatureEnabled(AgentFeature.DYNAMIC_INSTRUMENTATION);
exceptionReplayEnabled = isFeatureEnabled(AgentFeature.EXCEPTION_REPLAY);
codeOriginEnabled = isFeatureEnabled(AgentFeature.CODE_ORIGIN);
agentlessLogSubmissionEnabled = isFeatureEnabled(AgentFeature.AGENTLESS_LOG_SUBMISSION);

if (profilingEnabled) {
Expand Down Expand Up @@ -1114,7 +1115,10 @@ private static void shutdownProfilingAgent(final boolean sync) {
}

private static void maybeStartDebugger(Instrumentation inst, Class<?> scoClass, Object sco) {
if (!debuggerEnabled && !exceptionDebuggingEnabled && !spanOriginEnabled) {
if (isExplicitlyDisabled(DebuggerConfig.DYNAMIC_INSTRUMENTATION_ENABLED)
&& isExplicitlyDisabled(DebuggerConfig.EXCEPTION_REPLAY_ENABLED)
&& isExplicitlyDisabled(TraceInstrumentationConfig.CODE_ORIGIN_FOR_SPANS_ENABLED)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we still want to bind code origin to DI enablement?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's not bond.

&& isExplicitlyDisabled(DebuggerConfig.DISTRIBUTED_DEBUGGER_ENABLED)) {
return;
}
if (!remoteConfigEnabled) {
Expand All @@ -1124,6 +1128,11 @@ private static void maybeStartDebugger(Instrumentation inst, Class<?> scoClass,
startDebuggerAgent(inst, scoClass, sco);
}

private static boolean isExplicitlyDisabled(String booleanKey) {
return Config.get().configProvider().isSet(booleanKey)
&& !Config.get().configProvider().getBoolean(booleanKey);
}

private static synchronized void startDebuggerAgent(
Instrumentation inst, Class<?> scoClass, Object sco) {
StaticEventLogger.begin("Debugger");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@ public String tag() {
public abstract String tag();
}

public interface ProductConfigUpdater {
void updateConfig(
Boolean dynamicInstrumentationEnabled,
Boolean exceptionReplayEnabled,
Boolean codeOriginEnabled,
Boolean liveDebuggingEnabled);

boolean isDynamicInstrumentationEnabled();

boolean isExceptionReplayEnabled();

boolean isCodeOriginEnabled();

boolean isDistributedDebuggerEnabled();
}

public interface ProbeResolver {
ProbeImplementation resolve(String encodedProbeId);
}
Expand Down Expand Up @@ -103,6 +119,7 @@ public interface CodeOriginRecorder {
String captureCodeOrigin(Method method, boolean entry, boolean instrument);
}

private static volatile ProductConfigUpdater productConfigUpdater;
private static volatile ProbeResolver probeResolver;
private static volatile ClassFilter classFilter;
private static volatile ClassNameFilter classNameFilter;
Expand All @@ -112,6 +129,10 @@ public interface CodeOriginRecorder {
private static volatile ExceptionDebugger exceptionDebugger;
private static volatile CodeOriginRecorder codeOriginRecorder;

public static void initProductConfigUpdater(ProductConfigUpdater productConfigUpdater) {
DebuggerContext.productConfigUpdater = productConfigUpdater;
}

public static void initProbeResolver(ProbeResolver probeResolver) {
DebuggerContext.probeResolver = probeResolver;
}
Expand Down Expand Up @@ -144,6 +165,59 @@ public static void initCodeOrigin(CodeOriginRecorder codeOriginRecorder) {
DebuggerContext.codeOriginRecorder = codeOriginRecorder;
}

public static void updateConfig(
Boolean dynamicInstrumentationEnabled,
Boolean exceptionReplayEnabled,
Boolean codeOriginEnabled,
Boolean liveDebuggingEnabled) {
LOGGER.debug(
"Updating config: dynamicInstrumentationEnabled: {}, exceptionReplayEnabled: {}, codeOriginEnabled: {}, liveDebuggingEnabled: {}",
dynamicInstrumentationEnabled,
exceptionReplayEnabled,
codeOriginEnabled,
liveDebuggingEnabled);
ProductConfigUpdater updater = productConfigUpdater;
if (updater != null) {
updater.updateConfig(
dynamicInstrumentationEnabled,
exceptionReplayEnabled,
codeOriginEnabled,
liveDebuggingEnabled);
}
}

public static boolean isDynamicInstrumentationEnabled() {
ProductConfigUpdater updater = productConfigUpdater;
if (updater != null) {
return updater.isDynamicInstrumentationEnabled();
}
return Config.get().isDynamicInstrumentationEnabled();
}

public static boolean isExceptionReplayEnabled() {
ProductConfigUpdater updater = productConfigUpdater;
if (updater != null) {
return updater.isExceptionReplayEnabled();
}
return Config.get().isDebuggerExceptionEnabled();
}

public static boolean isCodeOriginEnabled() {
ProductConfigUpdater updater = productConfigUpdater;
if (updater != null) {
return updater.isCodeOriginEnabled();
}
return Config.get().isDebuggerCodeOriginEnabled();
}

public static boolean isDistributedDebuggerEnabled() {
ProductConfigUpdater updater = productConfigUpdater;
if (updater != null) {
return updater.isDistributedDebuggerEnabled();
}
return Config.get().isDistributedDebuggerEnabled();
}

/**
* Returns the probe details based on the probe id provided. If no probe is found, try to
* re-transform the class using the callingClass parameter No-op if no implementation available
Expand Down
Loading
Loading