Skip to content

Commit 71799ce

Browse files
committed
Debug MetadataNormalisationTest
1 parent f36b049 commit 71799ce

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

ddprof-test/src/test/java/com/datadoghq/profiler/AbstractProfilerTest.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,4 +378,29 @@ protected void verifyStackTraces(Path recording, String eventType, String... pat
378378
assertNotEquals(0, cumulatedEvents, "no events found for " + eventType);
379379
assertTrue(unmatched.isEmpty(), "couldn't find " + eventType + " with " + unmatched);
380380
}
381+
382+
protected final void checkContentionDrops() {
383+
// Check profiler counters for contention drops
384+
IItemCollection profilerCounters = verifyEvents("datadog.ProfilerCounter");
385+
long contentionDrops = 0;
386+
int countersNum = 0;
387+
outer:
388+
for (IItemIterable counters : profilerCounters) {
389+
countersNum++;
390+
IMemberAccessor<String, IItem> nameAccessor = NAME.getAccessor(counters.getType());
391+
IMemberAccessor<IQuantity, IItem> countAccessor = COUNT.getAccessor(counters.getType());
392+
for (IItem item : counters) {
393+
String name = nameAccessor.getMember(item);
394+
if ("calltrace_storage_dropped_traces".equals(name)) {
395+
IQuantity value = countAccessor.getMember(item);
396+
if (value != null) {
397+
contentionDrops = value.longValue();
398+
break outer;
399+
}
400+
}
401+
}
402+
}
403+
assertTrue(countersNum > 0, "There should be at least one profiler counter");
404+
System.out.println("Contention drops detected: " + contentionDrops);
405+
}
381406
}

ddprof-test/src/test/java/com/datadoghq/profiler/cpu/ContextCpuTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public void test(@CStack String cstack) throws ExecutionException, InterruptedEx
5151
stopProfiler();
5252

5353
verifyCStackSettings();
54+
checkContentionDrops();
5455

5556
Set<Long> method1SpanIds = profiledCode.spanIdsForMethod("method1Impl");
5657
Set<Long> method2SpanIds = profiledCode.spanIdsForMethod("method2Impl");

ddprof-test/src/test/java/com/datadoghq/profiler/metadata/MetadataNormalisationTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.openjdk.jmc.common.item.IItemCollection;
77
import org.openjdk.jmc.common.item.IItemIterable;
88
import org.openjdk.jmc.common.item.IMemberAccessor;
9+
import org.openjdk.jmc.common.unit.IQuantity;
910
import org.openjdk.jmc.flightrecorder.jdk.JdkAttributes;
1011

1112
import java.lang.reflect.Constructor;
@@ -18,6 +19,7 @@
1819
import java.util.stream.Stream;
1920

2021
import static org.junit.jupiter.api.Assertions.assertFalse;
22+
import static org.junit.jupiter.api.Assertions.assertTrue;
2123

2224
public class MetadataNormalisationTest extends AbstractProfilerTest {
2325

@@ -42,6 +44,9 @@ public void test() throws Exception {
4244
System.out.println(count);
4345
stopProfiler();
4446
IItemCollection executionSamples = verifyEvents("datadog.ExecutionSample");
47+
48+
checkContentionDrops();
49+
4550
Matcher[] forbiddenPatternMatchers = Stream.of(
4651
"MH.*0x[A-Fa-f0-9]{3}", // method handles
4752
"GeneratedConstructorAccessor\\d+",

0 commit comments

Comments
 (0)