Search in sources :

Example 11 with RequestTraceSpan

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

Example 12 with RequestTraceSpan

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

Example 13 with RequestTraceSpan

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

Example 14 with RequestTraceSpan

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

Example 15 with RequestTraceSpan

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

Aggregations

RequestTraceSpan (fish.payara.notification.requesttracing.RequestTraceSpan)30 Test (org.junit.Test)13 FaultToleranceService (fish.payara.microprofile.faulttolerance.FaultToleranceService)3 RequestTrace (fish.payara.notification.requesttracing.RequestTrace)3 UUID (java.util.UUID)3 InvocationManager (org.glassfish.api.invocation.InvocationManager)3 Principal (java.security.Principal)2 ServletException (javax.servlet.ServletException)2 Config (org.eclipse.microprofile.config.Config)2 Endpoint (org.glassfish.webservices.monitoring.Endpoint)2 JndiNameEnvironment (com.sun.enterprise.deployment.JndiNameEnvironment)1 WebServiceEndpoint (com.sun.enterprise.deployment.WebServiceEndpoint)1 SecurityContext (com.sun.enterprise.security.SecurityContext)1 WebPrincipal (com.sun.enterprise.security.web.integration.WebPrincipal)1 ServletAdapter (com.sun.xml.ws.transport.http.servlet.ServletAdapter)1 RequestTracingService (fish.payara.nucleus.requesttracing.RequestTracingService)1 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1 URL (java.net.URL)1 ChronoUnit (java.time.temporal.ChronoUnit)1