use of fish.payara.notification.requesttracing.RequestTracingNotificationData in project Payara by payara.
the class CDIEventbusNotificationEventFactory method buildNotificationEvent.
@Override
public CDIEventbusNotificationEvent buildNotificationEvent(String subject, RequestTrace requestTrace) {
CDIEventbusNotificationEvent event = initializeEvent(createEventInstance());
event.setSubject(subject);
event.setMessage(requestTrace.toString());
event.setNotificationData(new RequestTracingNotificationData(requestTrace));
return event;
}
use of fish.payara.notification.requesttracing.RequestTracingNotificationData in project Payara by payara.
the class EventbusNotificationEventFactory method buildNotificationEvent.
@Override
public EventbusNotificationEvent buildNotificationEvent(String subject, RequestTrace requestTrace) {
EventbusNotificationEvent event = initializeEvent(createEventInstance());
event.setSubject(subject);
event.setMessage(requestTrace.toString());
event.setNotificationData(new RequestTracingNotificationData(requestTrace));
event.setInstanceName(hazelcast.getUUID());
return event;
}
use of fish.payara.notification.requesttracing.RequestTracingNotificationData in project Payara by payara.
the class TraceMonitor method observe.
public void observe(@Observes @Inbound EventbusMessage event) {
logger.info("CDI notifier: " + event.getMessage());
if (event.getData() instanceof RequestTracingNotificationData) {
RequestTracingNotificationData notificationData = (RequestTracingNotificationData) event.getData();
List<RequestTraceSpan> spans = notificationData.getRequestTrace().getTraceSpans();
for (RequestTraceSpan span : spans) {
if ("customOperation".equals(span.getEventName())) {
observerCalled = true;
}
}
}
}
use of fish.payara.notification.requesttracing.RequestTracingNotificationData in project Payara by payara.
the class RequestTracingService method processTraceEnd.
private void processTraceEnd() {
Long thresholdValueInNanos = getThresholdValueInNanos();
long elapsedTime = requestEventStore.getElapsedTime();
long elapsedTimeInNanos = TimeUnit.NANOSECONDS.convert(elapsedTime, TimeUnit.MILLISECONDS);
if (elapsedTimeInNanos - thresholdValueInNanos > 0) {
// Determine whether to sample the request, if sampleRateFirstEnabled is false
if (!executionOptions.getSampleRateFirstEnabled()) {
if (!sampleFilter.sample()) {
requestEventStore.flushStore();
return;
}
}
// collect any trace exceeding the threshold
if (uncollectedTraces.size() >= 50) {
// avoid queue creating a memory leak by accumulating entries in case no consumer polls them
uncollectedTraces.poll();
}
RequestTrace requestTrace = requestEventStore.getTrace();
uncollectedTraces.add(requestTrace);
Runnable addTask = () -> {
RequestTrace removedTrace = requestTraceStore.addTrace(requestTrace);
// Store the trace in the historic trace store if it's enabled, avoiding recalculation
if (executionOptions.isHistoricTraceStoreEnabled()) {
historicRequestTraceStore.addTrace(requestTrace, removedTrace);
}
if (removedTrace != null) {
if (hazelcast.isEnabled()) {
eventBus.publish(EVENT_BUS_LISTENER_NAME, new ClusterMessage(RequestTracingEvents.STORE_FULL.toString()));
} else {
events.send(new EventListener.Event(RequestTracingEvents.STORE_FULL));
}
}
};
payaraExecutorService.submit(addTask);
Collection<String> enabledNotifiers = getExecutionOptions().getEnabledNotifiers();
PayaraNotification notification = notificationFactory.newBuilder().whitelist(enabledNotifiers.toArray(new String[0])).subject("Request execution time: " + elapsedTime + "(ms) exceeded the acceptable threshold").message(requestTrace.toString()).data(new RequestTracingNotificationData(requestTrace)).build();
notificationEventBus.publish(notification);
}
requestEventStore.flushStore();
}
Aggregations