Skip to content

Commit

Permalink
Add Exception Replay config parameters (#7647)
Browse files Browse the repository at this point in the history
DD_EXCEPTION_REPLAY_CAPTURE_MAX_FRAMES alias on
DD_EXCEPTION_REPLAY_MAX_FRAMES_TO_CAPTURE
DD_EXCEPTION_REPLAY_CAPTURE_INTERVAL_SECONDS interval in seconds
between 2 capture of the same exceptions
DD_EXCEPTION_REPLAY_CAPTURE_INTERMEDIATE_SPANS_ENABLED inverted alias
on DD_EXCEPTION_REPLAY_ONLY_LOCAL_ROOT
  • Loading branch information
jpbempel authored and shatzi committed Sep 25, 2024
1 parent fa39382 commit 80ad360
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 6 deletions.
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 @@ -95,7 +94,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 =
"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
5 changes: 4 additions & 1 deletion dd-trace-core/src/main/java/datadog/trace/core/DDSpan.java
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 @@ -2005,9 +2012,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 @@ -3390,10 +3407,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

0 comments on commit 80ad360

Please sign in to comment.