Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,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 @@ -154,9 +154,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 @@ -272,9 +273,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 @@ -1133,7 +1134,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)
&& isExplicitlyDisabled(DebuggerConfig.DISTRIBUTED_DEBUGGER_ENABLED)) {
return;
}
if (!remoteConfigEnabled) {
Expand All @@ -1143,6 +1147,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