Search in sources :

Example 16 with RequestTrace

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);
}
Also used : RequestTraceSpan(fish.payara.notification.requesttracing.RequestTraceSpan) RequestTrace(fish.payara.notification.requesttracing.RequestTrace) Test(org.junit.Test)

Example 17 with RequestTrace

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;
}
Also used : ArrayList(java.util.ArrayList) RequestTraceSpan(fish.payara.notification.requesttracing.RequestTraceSpan) RequestTrace(fish.payara.notification.requesttracing.RequestTrace) Tag(io.opentracing.tag.Tag) GroupData(fish.payara.monitoring.adapt.GroupData)

Example 18 with RequestTrace

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);
}
Also used : RequestTrace(fish.payara.notification.requesttracing.RequestTrace)

Example 19 with RequestTrace

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);
}
Also used : RequestTrace(fish.payara.notification.requesttracing.RequestTrace)

Example 20 with RequestTrace

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);
}
Also used : RequestTrace(fish.payara.notification.requesttracing.RequestTrace)

Aggregations

RequestTrace (fish.payara.notification.requesttracing.RequestTrace)25 Test (org.junit.Test)7 RequestTraceSpan (fish.payara.notification.requesttracing.RequestTraceSpan)6 ArrayList (java.util.ArrayList)4 ClusterMessage (fish.payara.nucleus.eventbus.ClusterMessage)2 LongestTraceStorageStrategy (fish.payara.nucleus.requesttracing.store.strategy.LongestTraceStorageStrategy)2 ReservoirTraceStorageStrategy (fish.payara.nucleus.requesttracing.store.strategy.ReservoirTraceStorageStrategy)2 TraceStorageStrategy (fish.payara.nucleus.requesttracing.store.strategy.TraceStorageStrategy)2 ClusteredStore (fish.payara.nucleus.store.ClusteredStore)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)2 Instant (java.time.Instant)2 UUID (java.util.UUID)2 MultiMap (com.hazelcast.core.MultiMap)1 ColumnFormatter (com.sun.enterprise.util.ColumnFormatter)1 PayaraNotification (fish.payara.internal.notification.PayaraNotification)1 GroupData (fish.payara.monitoring.adapt.GroupData)1 MonitoringData (fish.payara.monitoring.collect.MonitoringData)1 RequestTracingNotificationData (fish.payara.notification.requesttracing.RequestTracingNotificationData)1 LogNotifierExecutionOptions (fish.payara.nucleus.notification.log.LogNotifierExecutionOptions)1 RequestTracingExecutionOptions (fish.payara.nucleus.requesttracing.domain.execoptions.RequestTracingExecutionOptions)1