Search in sources :

Example 6 with RequestTrace

use of fish.payara.notification.requesttracing.RequestTrace in project Payara by payara.

the class AbstractRequestTraceStoreTest method createTrace.

protected static RequestTrace createTrace(long durationNanos) {
    RequestTrace trace = new RequestTrace();
    RequestTraceSpan span = new RequestTraceSpan(EventType.TRACE_START, "op1");
    Instant start = Instant.now().minusNanos(durationNanos);
    span.setStartInstant(start);
    trace.addEvent(span);
    trace.endTrace();
    return trace;
}
Also used : Instant(java.time.Instant) RequestTraceSpan(fish.payara.notification.requesttracing.RequestTraceSpan) RequestTrace(fish.payara.notification.requesttracing.RequestTrace)

Example 7 with RequestTrace

use of fish.payara.notification.requesttracing.RequestTrace in project Payara by payara.

the class LongestTraceStorageStrategyTest method shortestTraceIsRemovedAboveMaxSize.

@Test
public void shortestTraceIsRemovedAboveMaxSize() {
    int maxSize = 10;
    List<RequestTrace> traces = new ArrayList<>();
    for (int i = 0; i < maxSize; i++) {
        // 1-10sec long traces
        traces.add(createTrace(1000000000L * (i + 1)));
    }
    List<RequestTrace> added = new ArrayList<>();
    List<RequestTrace> removed = new ArrayList<>();
    for (int i = 0; i < maxSize; i++) {
        // 0.5-9.5ms long traces
        RequestTrace newTrace = createTrace(1000000000L * (i + 1) - 500000000L);
        added.add(newTrace);
        traces.add(newTrace);
        RequestTrace traceForRemoval = strategy.getTraceForRemoval(traces, maxSize, null);
        assertTrue(traceForRemoval.getElapsedTime() <= newTrace.getElapsedTime());
        for (int j = 0; j < maxSize; j++) {
            RequestTrace candidate = traces.get(j);
            assertSame(candidate, strategy.getTraceForRemoval(traces, maxSize, candidate));
        }
        removed.add(traceForRemoval);
        traces.remove(traceForRemoval);
    }
    // remaining elements should be half from the original 10 items, half from the later added ones
    added.removeAll(removed);
    assertEquals(maxSize / 2, added.size());
}
Also used : ArrayList(java.util.ArrayList) RequestTrace(fish.payara.notification.requesttracing.RequestTrace) Test(org.junit.Test)

Example 8 with RequestTrace

use of fish.payara.notification.requesttracing.RequestTrace in project Payara by payara.

the class RequestTraceSpanStore method endTrace.

void endTrace() {
    RequestTrace currentTrace = spanStore.get();
    currentTrace.endTrace();
}
Also used : RequestTrace(fish.payara.notification.requesttracing.RequestTrace)

Example 9 with RequestTrace

use of fish.payara.notification.requesttracing.RequestTrace in project Payara by payara.

the class RequestTraceSpanStore method endTrace.

void endTrace(long timestampMillis) {
    RequestTrace currentTrace = spanStore.get();
    currentTrace.endTrace(timestampMillis);
}
Also used : RequestTrace(fish.payara.notification.requesttracing.RequestTrace)

Example 10 with RequestTrace

use of fish.payara.notification.requesttracing.RequestTrace in project Payara by payara.

the class RequestTracingService method collect.

@Override
@MonitoringData(ns = "trace")
public void collect(MonitoringDataCollector collector) {
    for (String group : activeCollectionGroups.keySet()) {
        collector.group(group).collect(DURATION, 0);
        activeCollectionGroups.compute(group, (key, value) -> value <= 1 ? null : value - 1);
    }
    long thresholdInMillis = getConfigurationThresholdInMillis();
    RequestTrace trace = uncollectedTraces.poll();
    while (trace != null) {
        String group = collectTrace(collector, trace, thresholdInMillis);
        if (group != null) {
            activeCollectionGroups.compute(group, (key, value) -> 35);
        }
        trace = uncollectedTraces.poll();
    }
}
Also used : RequestTrace(fish.payara.notification.requesttracing.RequestTrace) MonitoringData(fish.payara.monitoring.collect.MonitoringData)

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