Skip to content

Commit 53be30c

Browse files
committed
Debug MetadataNormalisationTest
1 parent f36b049 commit 53be30c

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

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

Lines changed: 25 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,29 @@ public void test() throws Exception {
4244
System.out.println(count);
4345
stopProfiler();
4446
IItemCollection executionSamples = verifyEvents("datadog.ExecutionSample");
47+
48+
// Check profiler counters for contention drops
49+
IItemCollection profilerCounters = verifyEvents("datadog.ProfilerCounter");
50+
long contentionDrops = 0;
51+
int countersNum = 0;
52+
for (IItemIterable counters : profilerCounters) {
53+
countersNum++;
54+
IMemberAccessor<String, IItem> nameAccessor = NAME.getAccessor(counters.getType());
55+
IMemberAccessor<IQuantity, IItem> countAccessor = COUNT.getAccessor(counters.getType());
56+
for (IItem item : counters) {
57+
String name = nameAccessor.getMember(item);
58+
if ("calltrace_storage_dropped_traces".equals(name)) {
59+
IQuantity value = countAccessor.getMember(item);
60+
if (value != null) {
61+
contentionDrops = value.longValue();
62+
break;
63+
}
64+
}
65+
}
66+
if (contentionDrops > 0) break;
67+
}
68+
assertTrue(contentionDrops > 0, "Contention drops should be non-zero");
69+
System.out.println("Contention drops detected: " + contentionDrops);
4570
Matcher[] forbiddenPatternMatchers = Stream.of(
4671
"MH.*0x[A-Fa-f0-9]{3}", // method handles
4772
"GeneratedConstructorAccessor\\d+",

0 commit comments

Comments
 (0)