Search in sources :

Example 1 with RequestTracingNotificationData

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

Example 2 with RequestTracingNotificationData

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

Example 3 with RequestTracingNotificationData

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

Example 4 with RequestTracingNotificationData

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();
}
Also used : RequestTracingNotificationData(fish.payara.notification.requesttracing.RequestTracingNotificationData) PropertyChangeEvent(java.beans.PropertyChangeEvent) RequestTrace(fish.payara.notification.requesttracing.RequestTrace) PayaraNotification(fish.payara.internal.notification.PayaraNotification) ClusterMessage(fish.payara.nucleus.eventbus.ClusterMessage)

Aggregations

RequestTracingNotificationData (fish.payara.notification.requesttracing.RequestTracingNotificationData)4 PayaraNotification (fish.payara.internal.notification.PayaraNotification)1 RequestTrace (fish.payara.notification.requesttracing.RequestTrace)1 RequestTraceSpan (fish.payara.notification.requesttracing.RequestTraceSpan)1 ClusterMessage (fish.payara.nucleus.eventbus.ClusterMessage)1 PropertyChangeEvent (java.beans.PropertyChangeEvent)1