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;
}
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());
}
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();
}
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);
}
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();
}
}
Aggregations