-
Notifications
You must be signed in to change notification settings - Fork 359
Expand file tree
/
Copy pathDefaultExceptionDebugger.java
More file actions
63 lines (56 loc) · 2.17 KB
/
Copy pathDefaultExceptionDebugger.java
File metadata and controls
63 lines (56 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package com.datadog.debugger.exception;
import com.datadog.debugger.agent.ConfigurationUpdater;
import com.datadog.debugger.util.CircuitBreaker;
import datadog.trace.api.Config;
import datadog.trace.bootstrap.debugger.DebuggerContext;
import datadog.trace.bootstrap.debugger.DebuggerContext.ClassNameFilter;
import datadog.trace.bootstrap.instrumentation.api.AgentSpan;
import java.time.Duration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** Default implementation of {@link DebuggerContext.ExceptionDebugger} for Exception Replay. */
public class DefaultExceptionDebugger extends AbstractExceptionDebugger {
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultExceptionDebugger.class);
private final CircuitBreaker circuitBreaker;
public DefaultExceptionDebugger(
ConfigurationUpdater configurationUpdater,
ClassNameFilter classNameFiltering,
Config config) {
this(
new ExceptionProbeManager(
classNameFiltering, Duration.ofSeconds(config.getDebuggerExceptionCaptureInterval())),
configurationUpdater,
classNameFiltering,
config.getDebuggerMaxExceptionPerSecond(),
config.getDebuggerExceptionMaxCapturedFrames(),
true);
}
DefaultExceptionDebugger(
ExceptionProbeManager exceptionProbeManager,
ConfigurationUpdater configurationUpdater,
DebuggerContext.ClassNameFilter classNameFiltering,
int maxExceptionPerSecond,
int maxCapturedFrames,
boolean applyConfigAsync) {
super(
exceptionProbeManager,
configurationUpdater,
classNameFiltering,
maxCapturedFrames,
applyConfigAsync);
this.circuitBreaker = new CircuitBreaker(maxExceptionPerSecond, Duration.ofSeconds(1));
}
@Override
protected boolean shouldHandleException(Throwable t, AgentSpan span) {
if (t instanceof Error) {
return false;
}
// do not handle exception with no stacktrace. cannot capture anything for it.
// includes also FastThrow ones
StackTraceElement[] stackTrace = t.getStackTrace();
if (stackTrace == null || stackTrace.length == 0) {
return false;
}
return circuitBreaker.trip();
}
}