6
6
import org .openjdk .jmc .common .item .IItemCollection ;
7
7
import org .openjdk .jmc .common .item .IItemIterable ;
8
8
import org .openjdk .jmc .common .item .IMemberAccessor ;
9
+ import org .openjdk .jmc .common .unit .IQuantity ;
9
10
import org .openjdk .jmc .flightrecorder .jdk .JdkAttributes ;
10
11
11
12
import java .lang .reflect .Constructor ;
18
19
import java .util .stream .Stream ;
19
20
20
21
import static org .junit .jupiter .api .Assertions .assertFalse ;
22
+ import static org .junit .jupiter .api .Assertions .assertTrue ;
21
23
22
24
public class MetadataNormalisationTest extends AbstractProfilerTest {
23
25
@@ -42,6 +44,29 @@ public void test() throws Exception {
42
44
System .out .println (count );
43
45
stopProfiler ();
44
46
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 );
45
70
Matcher [] forbiddenPatternMatchers = Stream .of (
46
71
"MH.*0x[A-Fa-f0-9]{3}" , // method handles
47
72
"GeneratedConstructorAccessor\\ d+" ,
0 commit comments