Skip to content
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

Add Exception Replay config parameters #7647

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 @@ -48,7 +48,6 @@
/** Debugger agent implementation */
public class DebuggerAgent {
private static final Logger LOGGER = LoggerFactory.getLogger(DebuggerAgent.class);
public static final Duration EXCEPTION_CAPTURE_INTERVAL = Duration.ofHours(1);
private static ConfigurationPoller configurationPoller;
private static DebuggerSink sink;
private static String agentVersion;
Expand Down Expand Up @@ -99,7 +98,7 @@ public static synchronized void run(
new DefaultExceptionDebugger(
configurationUpdater,
classNameFiltering,
EXCEPTION_CAPTURE_INTERVAL,
Duration.ofSeconds(config.getDebuggerExceptionCaptureInterval()),
config.getDebuggerMaxExceptionPerSecond());
DebuggerContext.initExceptionDebugger(defaultExceptionDebugger);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,10 @@ public final class ConfigDefaults {
static final int DEFAULT_DEBUGGER_SYMBOL_FLUSH_THRESHOLD = 100; // nb of classes
static final boolean DEFAULT_DEBUGGER_EXCEPTION_ENABLED = false;
static final int DEFAULT_DEBUGGER_MAX_EXCEPTION_PER_SECOND = 100;
static final boolean DEFAULT_DEBUGGER_EXCEPTION_ONLY_LOCAL_ROOT = true;
static final boolean DEFAULT_DEBUGGER_EXCEPTION_ONLY_LOCAL_ROOT = false;
static final boolean DEFAULT_DEBUGGER_EXCEPTION_CAPTURE_INTERMEDIATE_SPANS_ENABLED = true;
static final int DEFAULT_DEBUGGER_EXCEPTION_MAX_CAPTURED_FRAMES = 3;
static final int DEFAULT_DEBUGGER_EXCEPTION_CAPTURE_INTERVAL_SECONDS = 60 * 60;
static final boolean DEFAULT_DEBUGGER_CODE_ORIGIN_ENABLED = false;

static final boolean DEFAULT_TRACE_REPORT_HOSTNAME = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ public final class DebuggerConfig {
"internal.exception.replay.only.local.root";
public static final String DEBUGGER_EXCEPTION_MAX_CAPTURED_FRAMES =
"exception.replay.max.frames.to.capture";
public static final String DEBUGGER_EXCEPTION_CAPTURE_MAX_FRAMES =
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick and not blocking, but given the similarity between both variable names (DEBUGGER_EXCEPTION_CAPTURE_MAX_FRAMES, DEBUGGER_EXCEPTION_MAX_CAPTURED_FRAMES) it was somewhat confusing when trying to follow in Config.java. It would make sense that the old variable (DEBUGGER_EXCEPTION_MAX_CAPTURED_FRAMES) was aligned with its actual env var form (e.g. DEBUGGER_REPLAY_MAX_FRAMES_TO_CAPTURE).

Copy link
Member Author

@jpbempel jpbempel Sep 19, 2024

Choose a reason for hiding this comment

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

I am trying to decouple what is inside the code what is exposed to the user because more than once we had renaming (debugger-> dynamic instrumentation, exception debugging -> exception replay) and if the code need to follow all the wave of renaming could be worse :)

"exception.replay.capture.max.frames";
public static final String DEBUGGER_EXCEPTION_CAPTURE_INTERVAL_SECONDS =
"exception.replay.capture.interval.seconds";
public static final String DEBUGGER_EXCEPTION_CAPTURE_INTERMEDIATE_SPANS_ENABLED =
"exception.replay.capture.intermediate.spans.enabled";
public static final String THIRD_PARTY_INCLUDES = "third.party.includes";
public static final String THIRD_PARTY_EXCLUDES = "third.party.excludes";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,10 @@ private boolean isExceptionDebuggingEnabled() {
if (!Config.get().isDebuggerExceptionEnabled()) {
return false;
}
if (Config.get().isDebuggerExceptionOnlyLocalRoot() && !isLocalRootSpan()) {
boolean captureOnlyRootSpan =
(Config.get().isDebuggerExceptionOnlyLocalRoot()
|| !Config.get().isDebuggerExceptionCaptureIntermediateSpansEnabled());
if (captureOnlyRootSpan && !isLocalRootSpan()) {
return false;
}
return true;
Expand Down
29 changes: 27 additions & 2 deletions internal-api/src/main/java/datadog/trace/api/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
import static datadog.trace.api.ConfigDefaults.DEFAULT_DEBUGGER_CODE_ORIGIN_ENABLED;
import static datadog.trace.api.ConfigDefaults.DEFAULT_DEBUGGER_DIAGNOSTICS_INTERVAL;
import static datadog.trace.api.ConfigDefaults.DEFAULT_DEBUGGER_ENABLED;
import static datadog.trace.api.ConfigDefaults.DEFAULT_DEBUGGER_EXCEPTION_CAPTURE_INTERMEDIATE_SPANS_ENABLED;
import static datadog.trace.api.ConfigDefaults.DEFAULT_DEBUGGER_EXCEPTION_CAPTURE_INTERVAL_SECONDS;
import static datadog.trace.api.ConfigDefaults.DEFAULT_DEBUGGER_EXCEPTION_ENABLED;
import static datadog.trace.api.ConfigDefaults.DEFAULT_DEBUGGER_EXCEPTION_MAX_CAPTURED_FRAMES;
import static datadog.trace.api.ConfigDefaults.DEFAULT_DEBUGGER_EXCEPTION_ONLY_LOCAL_ROOT;
Expand Down Expand Up @@ -225,6 +227,9 @@
import static datadog.trace.api.config.DebuggerConfig.DEBUGGER_CODE_ORIGIN_ENABLED;
import static datadog.trace.api.config.DebuggerConfig.DEBUGGER_DIAGNOSTICS_INTERVAL;
import static datadog.trace.api.config.DebuggerConfig.DEBUGGER_ENABLED;
import static datadog.trace.api.config.DebuggerConfig.DEBUGGER_EXCEPTION_CAPTURE_INTERMEDIATE_SPANS_ENABLED;
import static datadog.trace.api.config.DebuggerConfig.DEBUGGER_EXCEPTION_CAPTURE_INTERVAL_SECONDS;
import static datadog.trace.api.config.DebuggerConfig.DEBUGGER_EXCEPTION_CAPTURE_MAX_FRAMES;
import static datadog.trace.api.config.DebuggerConfig.DEBUGGER_EXCEPTION_ENABLED;
import static datadog.trace.api.config.DebuggerConfig.DEBUGGER_EXCEPTION_MAX_CAPTURED_FRAMES;
import static datadog.trace.api.config.DebuggerConfig.DEBUGGER_EXCEPTION_ONLY_LOCAL_ROOT;
Expand Down Expand Up @@ -884,8 +889,10 @@ public static String getHostName() {
private final int debuggerSymbolFlushThreshold;
private final boolean debuggerExceptionEnabled;
private final int debuggerMaxExceptionPerSecond;
private final boolean debuggerExceptionOnlyLocalRoot;
@Deprecated private final boolean debuggerExceptionOnlyLocalRoot;
private final boolean debuggerExceptionCaptureIntermediateSpansEnabled;
private final int debuggerExceptionMaxCapturedFrames;
private final int debuggerExceptionCaptureInterval;
private final boolean debuggerCodeOriginEnabled;

private final Set<String> debuggerThirdPartyIncludes;
Expand Down Expand Up @@ -2000,9 +2007,19 @@ PROFILING_DATADOG_PROFILER_ENABLED, isDatadogProfilerSafeInCurrentEnvironment())
debuggerExceptionOnlyLocalRoot =
configProvider.getBoolean(
DEBUGGER_EXCEPTION_ONLY_LOCAL_ROOT, DEFAULT_DEBUGGER_EXCEPTION_ONLY_LOCAL_ROOT);
debuggerExceptionCaptureIntermediateSpansEnabled =
configProvider.getBoolean(
DEBUGGER_EXCEPTION_CAPTURE_INTERMEDIATE_SPANS_ENABLED,
DEFAULT_DEBUGGER_EXCEPTION_CAPTURE_INTERMEDIATE_SPANS_ENABLED);
debuggerExceptionMaxCapturedFrames =
configProvider.getInteger(
DEBUGGER_EXCEPTION_MAX_CAPTURED_FRAMES, DEFAULT_DEBUGGER_EXCEPTION_MAX_CAPTURED_FRAMES);
DEBUGGER_EXCEPTION_MAX_CAPTURED_FRAMES,
DEFAULT_DEBUGGER_EXCEPTION_MAX_CAPTURED_FRAMES,
DEBUGGER_EXCEPTION_CAPTURE_MAX_FRAMES);
debuggerExceptionCaptureInterval =
configProvider.getInteger(
DEBUGGER_EXCEPTION_CAPTURE_INTERVAL_SECONDS,
DEFAULT_DEBUGGER_EXCEPTION_CAPTURE_INTERVAL_SECONDS);

debuggerThirdPartyIncludes = tryMakeImmutableSet(configProvider.getList(THIRD_PARTY_INCLUDES));
debuggerThirdPartyExcludes = tryMakeImmutableSet(configProvider.getList(THIRD_PARTY_EXCLUDES));
Expand Down Expand Up @@ -3403,10 +3420,18 @@ public boolean isDebuggerExceptionOnlyLocalRoot() {
return debuggerExceptionOnlyLocalRoot;
}

public boolean isDebuggerExceptionCaptureIntermediateSpansEnabled() {
return debuggerExceptionCaptureIntermediateSpansEnabled;
}

public int getDebuggerExceptionMaxCapturedFrames() {
return debuggerExceptionMaxCapturedFrames;
}

public int getDebuggerExceptionCaptureInterval() {
return debuggerExceptionCaptureInterval;
}

public boolean isDebuggerCodeOriginEnabled() {
return debuggerCodeOriginEnabled;
}
Expand Down