use of fish.payara.notification.requesttracing.RequestTrace 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.RequestTrace in project Payara by payara.
the class MonitoringConsoleRuntimeImpl method selectAll.
@Override
public Collection<GroupData> selectAll(String source, String group) {
if (!"requesttracing".equals(source)) {
return emptyList();
}
List<GroupData> matches = new ArrayList<>();
for (RequestTrace trace : requestTracingService.getRequestTraceStore().getTraces()) {
if (RequestTracingService.metricGroupName(trace).equals(group)) {
GroupData data = new GroupData();
data.addField("id", trace.getTraceId()).addField("startTime", trace.getStartTime().toEpochMilli()).addField("endTime", trace.getEndTime().toEpochMilli()).addField("elapsedTime", trace.getElapsedTime());
for (RequestTraceSpan span : trace.getTraceSpans()) {
GroupData tags = data.addChild(span.getId().toString()).addField("id", span.getId()).addField("operation", RequestTracingService.stripPackageName(span.getEventName())).addField("startTime", span.getTimeOccured()).addField("endTime", span.getTraceEndTime().toEpochMilli()).addField("duration", span.getSpanDuration()).addChild("tags");
for (Entry<Object, String> tag : span.getSpanTags().entrySet()) {
if (tag.getKey() instanceof Tag) {
tags.addField(((Tag) tag.getKey()).getKey(), tag.getValue());
} else {
tags.addField(tag.getKey().toString(), tag.getValue());
}
}
}
matches.add(data);
}
}
return matches;
}
use of fish.payara.notification.requesttracing.RequestTrace in project Payara by payara.
the class RequestTraceSpanStore method setTraceId.
void setTraceId(UUID newID) {
RequestTrace trace = spanStore.get();
trace.setTraceId(newID);
}
use of fish.payara.notification.requesttracing.RequestTrace in project Payara by payara.
the class RequestTraceSpanStore method storeEvent.
void storeEvent(RequestTraceSpan payaraSpan, long timestampMillis) {
RequestTrace currentTrace = spanStore.get();
currentTrace.addEvent(payaraSpan, timestampMillis);
}
use of fish.payara.notification.requesttracing.RequestTrace in project Payara by payara.
the class RequestTraceSpanStore method storeEvent.
/**
* Adds a new event to the request trace
* @param payaraSpan
*/
void storeEvent(RequestTraceSpan payaraSpan) {
RequestTrace currentTrace = spanStore.get();
currentTrace.addEvent(payaraSpan);
}
Aggregations