use of jdk.jfr.EventType in project splunk-otel-java by signalfx.
the class EventProcessingChainTest method testLifecycle.
@Test
void testLifecycle() {
EventType contextAttachedType = newEventType(ContextAttached.EVENT_NAME);
EventType threadDumpType = newEventType(ThreadDumpProcessor.EVENT_NAME);
EventType tlabType = newEventType(TLABProcessor.NEW_TLAB_EVENT_NAME);
Instant now = Instant.now();
RecordedEvent tlab1 = newEvent(tlabType, now.minus(100, ChronoUnit.MILLIS));
RecordedEvent tlab2 = newEvent(tlabType, now.plus(100, ChronoUnit.MILLIS));
// context even happens after the thread dump but is seen first
RecordedEvent contextEvent = newEvent(contextAttachedType, now);
RecordedEvent threadDump = newEvent(threadDumpType, now.minus(250, ChronoUnit.MILLIS));
EventProcessingChain chain = new EventProcessingChain(contextualizer, threadDumpProcessor, tlabProcessor);
chain.accept(tlab1);
chain.accept(contextEvent);
chain.accept(tlab2);
chain.accept(threadDump);
verifyNoInteractions(contextualizer, threadDumpProcessor, tlabProcessor);
chain.flushBuffer();
InOrder inOrder = inOrder(contextualizer, threadDumpProcessor, tlabProcessor);
inOrder.verify(threadDumpProcessor).accept(threadDump);
inOrder.verify(tlabProcessor).accept(tlab1);
inOrder.verify(contextualizer).updateContext(contextEvent);
inOrder.verify(tlabProcessor).accept(tlab2);
inOrder.verifyNoMoreInteractions();
}
use of jdk.jfr.EventType in project splunk-otel-java by signalfx.
the class EventProcessingChainTest method newEventType.
private EventType newEventType(String name) {
EventType type = mock(EventType.class);
when(type.getName()).thenReturn(name);
return type;
}
use of jdk.jfr.EventType in project splunk-otel-java by signalfx.
the class EventProcessingChainTest method eventsDispatchedInTimeOrder.
@Test
void eventsDispatchedInTimeOrder() {
EventType contextAttachedType = newEventType(ContextAttached.EVENT_NAME);
EventType threadDumpType = newEventType(ThreadDumpProcessor.EVENT_NAME);
Instant now = Instant.now();
RecordedEvent event1 = newEvent(contextAttachedType, now.plus(1, SECONDS));
RecordedEvent event2 = newEvent(contextAttachedType, now.plus(2, SECONDS));
RecordedEvent event3 = newEvent(threadDumpType, now.plus(3, SECONDS));
RecordedEvent event4 = newEvent(null, null);
// Our events are in time order: context1, context2, threadDump1, threadDump2.
// However, we will send them to the chain out of order: context2, context1, threadDump.
// Expectation is that we see them dispatched in the correct order.
// The "chunk" is finished only after event4, and event4 is part of a new chunk so is not
// dispatched.
EventProcessingChain.ChunkTracker chunkTracker = mock(EventProcessingChain.ChunkTracker.class);
when(chunkTracker.isNewChunk(isA(RecordedEvent.class))).thenReturn(false, false, false, true);
EventProcessingChain chain = new EventProcessingChain(contextualizer, threadDumpProcessor, tlabProcessor, chunkTracker);
// Out of order
chain.accept(event2);
// Out of order
chain.accept(event1);
chain.accept(event3);
chain.accept(event4);
InOrder ordered = inOrder(contextualizer, threadDumpProcessor);
ordered.verify(contextualizer).updateContext(event1);
ordered.verify(contextualizer).updateContext(event2);
ordered.verify(threadDumpProcessor).accept(event3);
ordered.verifyNoMoreInteractions();
}
use of jdk.jfr.EventType in project splunk-otel-java by signalfx.
the class RelevantEventsTest method type.
private EventType type(String name) {
EventType type = mock(EventType.class);
when(type.getName()).thenReturn(name);
return type;
}
use of jdk.jfr.EventType in project btrace by btraceio.
the class BTraceFunctionalTests method testJfr.
@Test
public void testJfr() throws Exception {
debugBTrace = true;
debugTestApp = true;
String rtVersion = System.getProperty("java.runtime.version", "");
String testJavaHome = System.getenv().get("TEST_JAVA_HOME");
if (testJavaHome != null) {
Properties releaseProps = new Properties();
releaseProps.load(new FileInputStream(new File(testJavaHome + File.separator + "release")));
rtVersion = releaseProps.getProperty("JAVA_VERSION").replace("\"", "");
}
if (!isVersionSafe(rtVersion)) {
// skip the test for 8.0.* because of missing support
// skip all non-LTS versions (except the last one)
// skip the test for JDK 11 since the latest version 11.0.9 and newer ends in SISGSEGV
System.err.println("Skipping test for JDK " + rtVersion);
return;
}
testWithJfr("resources.Main", "btrace/JfrTest.java", 10, new ResultValidator() {
@Override
public void validate(String stdout, String stderr, int retcode, String jfrFile) {
assertFalse(stdout.contains("FAILED"), "Script should not have failed");
assertTrue(stderr.isEmpty(), "Non-empty stderr");
assertNotNull(jfrFile);
try {
RecordingFile f = new RecordingFile(Paths.get(jfrFile));
boolean hasPeriodicType = false, hasPeriodicValue = false, hasCustomType = false, hasCustomValue = false;
for (EventType et : f.readEventTypes()) {
if (et.getName().equals("periodic")) {
hasPeriodicType = true;
} else if (et.getName().equals("custom")) {
hasCustomType = true;
}
if (hasPeriodicType && hasCustomType) {
while (f.hasMoreEvents()) {
RecordedEvent e = f.readEvent();
if (e.getEventType().getName().equals("periodic")) {
hasPeriodicValue = true;
} else if (e.getEventType().getName().equals("custom")) {
hasCustomValue = true;
}
if (hasPeriodicValue && hasCustomValue) {
return;
}
}
break;
}
}
fail("periodic type ok: " + hasPeriodicType + ", periodic value ok: " + hasPeriodicValue + ", custom type ok: " + hasCustomType + ", custom value ok: " + hasCustomValue);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
});
}
Aggregations