Skip to content

Commit 86231f4

Browse files
authored
Fix flaky exception debugger test (#7084)
ensure the probes are installed before generating the snapshots
1 parent 51ffd4b commit 86231f4

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

dd-java-agent/agent-debugger/src/test/java/com/datadog/debugger/exception/DefaultExceptionDebuggerTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,13 @@ public void doubleHandleException() {
9595
@Test
9696
public void nestedException() {
9797
RuntimeException exception = createNestException();
98+
String fingerprint = Fingerprinter.fingerprint(exception, classNameFiltering);
9899
AgentSpan span = mock(AgentSpan.class);
99100
doAnswer(this::recordTags).when(span).setTag(anyString(), anyString());
100101
exceptionDebugger.handleException(exception, span);
102+
assertWithTimeout(
103+
() -> exceptionDebugger.getExceptionProbeManager().isAlreadyInstrumented(fingerprint),
104+
Duration.ofSeconds(30));
101105
generateSnapshots(exception);
102106
exception.printStackTrace();
103107
exceptionDebugger.handleException(exception, span);
@@ -144,7 +148,9 @@ public void nestedException() {
144148
@Test
145149
public void doubleNestedException() {
146150
RuntimeException nestedException = createNestException();
151+
String nestedFingerprint = Fingerprinter.fingerprint(nestedException, classNameFiltering);
147152
RuntimeException simpleException = new RuntimeException("test");
153+
String simpleFingerprint = Fingerprinter.fingerprint(simpleException, classNameFiltering);
148154
AgentSpan span = mock(AgentSpan.class);
149155
doAnswer(this::recordTags).when(span).setTag(anyString(), anyString());
150156
when(span.getTag(anyString()))
@@ -154,6 +160,12 @@ public void doubleNestedException() {
154160
exceptionDebugger.handleException(nestedException, span);
155161
// instrument first simple Exception
156162
exceptionDebugger.handleException(simpleException, span);
163+
assertWithTimeout(
164+
() -> exceptionDebugger.getExceptionProbeManager().isAlreadyInstrumented(nestedFingerprint),
165+
Duration.ofSeconds(30));
166+
assertWithTimeout(
167+
() -> exceptionDebugger.getExceptionProbeManager().isAlreadyInstrumented(simpleFingerprint),
168+
Duration.ofSeconds(30));
157169
generateSnapshots(nestedException);
158170
generateSnapshots(simpleException);
159171
exceptionDebugger.handleException(simpleException, span);

0 commit comments

Comments
 (0)