use of fish.payara.notification.requesttracing.RequestTraceSpan in project Payara by payara.
the class RequestEventStoreTest method testFlushMultipleThreads.
@Test
public void testFlushMultipleThreads() throws InterruptedException {
// thread 1 builds up a trace
Thread thread1 = new Thread(new Runnable() {
@Override
public void run() {
long threadID = Thread.currentThread().getId();
RequestTraceSpan re = new RequestTraceSpan(EventType.TRACE_START, "Start" + threadID);
eventStore.storeEvent(re);
for (int i = 0; i < 10; i++) {
re = new RequestTraceSpan("Event-" + i + "-" + threadID);
try {
Thread.sleep(10);
} catch (InterruptedException ex) {
Logger.getLogger(RequestEventStoreTest.class.getName()).log(Level.SEVERE, null, ex);
}
eventStore.storeEvent(re);
}
eventStore.endTrace();
tracesbyThreadId.put(threadID, eventStore.getTrace());
}
});
// thread 2 continually flushes the store
Thread thread2 = new Thread(new Runnable() {
@Override
public void run() {
long threadID = Thread.currentThread().getId();
for (int i = 0; i < 10; i++) {
try {
Thread.sleep(10);
} catch (InterruptedException ex) {
Logger.getLogger(RequestEventStoreTest.class.getName()).log(Level.SEVERE, null, ex);
}
eventStore.flushStore();
}
tracesbyThreadId.put(threadID, eventStore.getTrace());
}
});
thread1.start();
thread2.start();
thread1.join();
thread2.join();
RequestTrace trace1 = tracesbyThreadId.get(thread1.getId());
RequestTrace trace2 = tracesbyThreadId.get(thread2.getId());
// check trace sizes
assertEquals(11, trace1.getTraceSpans().size());
assertEquals(0, trace2.getTraceSpans().size());
// check trace 1 has an elapsed time in the correct range
assertTrue(trace1.getElapsedTime() >= 90);
}
use of fish.payara.notification.requesttracing.RequestTraceSpan in project Payara by payara.
the class RequestEventStoreTest method isInProgress.
@Test
public void isInProgress() {
assertFalse(eventStore.isTraceInProgress());
RequestTraceSpan re = new RequestTraceSpan(EventType.TRACE_START, "Start");
eventStore.storeEvent(re);
for (int i = 0; i < 10; i++) {
re = new RequestTraceSpan("Event-" + i);
try {
Thread.sleep(10);
} catch (InterruptedException ex) {
Logger.getLogger(RequestEventStoreTest.class.getName()).log(Level.SEVERE, null, ex);
}
eventStore.storeEvent(re);
}
assertTrue(eventStore.isTraceInProgress());
// eventStore.storeEvent(new RequesTraceSpan(EventType.TRACE_END, "End"));
eventStore.endTrace();
assertFalse(eventStore.isTraceInProgress());
}
use of fish.payara.notification.requesttracing.RequestTraceSpan in project Payara by payara.
the class RequestEventStoreTest method testStoreEvent.
@Test
public void testStoreEvent() {
RequestTraceSpan re = new RequestTraceSpan(EventType.TRACE_START, "Start");
eventStore.storeEvent(re);
eventStore.storeEvent(new RequestTraceSpan("Test"));
eventStore.endTrace();
assertEquals(2, eventStore.getTrace().getTraceSpans().size());
}
use of fish.payara.notification.requesttracing.RequestTraceSpan in project Payara by payara.
the class RequestTraceTest method testFullStream.
@Test
public void testFullStream() throws InterruptedException {
RequestTraceSpan re = new RequestTraceSpan(EventType.TRACE_START, "Start");
trace.addEvent(re);
for (int i = 0; i < 10000; i++) {
re = new RequestTraceSpan("Event" + i);
trace.addEvent(re);
}
Thread.sleep(10);
trace.endTrace();
assertTrue(trace.isStarted());
assertEquals(10001, trace.getTraceSpans().size());
assertTrue(trace.getElapsedTime() > 0);
}
use of fish.payara.notification.requesttracing.RequestTraceSpan in project Payara by payara.
the class RequestTraceTest method testConversationIDPropagation.
@Test
public void testConversationIDPropagation() {
RequestTraceSpan start = new RequestTraceSpan(EventType.TRACE_START, "Start");
trace.addEvent(start);
RequestTraceSpan re = new RequestTraceSpan("Event");
trace.addEvent(re);
assertEquals(start.getTraceId(), re.getTraceId());
trace.endTrace();
assertEquals(start.getTraceId(), re.getTraceId());
}
Aggregations