Search in sources :

Example 6 with AfterOperationEvent

use of kieker.common.record.flow.trace.operation.AfterOperationEvent in project iobserve-analysis by research-iobserve.

the class SessionAndTraceRegistrationFilter method doFilter.

/**
 * Register thread-local session and trace information, executes the given {@link FilterChain}
 * and unregisters the session/trace information. If configured, the execution of this filter is
 * also logged to the {@link IMonitoringController}. This method returns immediately if
 * monitoring is not enabled.
 *
 * @param request
 *            The request.
 * @param response
 *            The response.
 * @param chain
 *            The filter chain to be used.
 *
 * @throws IOException
 *             on io errors
 * @throws ServletException
 *             on servlet errors
 */
@Override
public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException {
    if (SessionAndTraceRegistrationFilter.CTRLINST.isMonitoringEnabled()) {
        // if (CTRLINST.isProbeActivated(this.filterOperationSignatureString)) {
        final String operationSignature;
        final String componentSignature;
        final String method;
        final String path;
        final String sessionId;
        String query;
        if (request instanceof HttpServletRequest) {
            final HttpServletRequest httpRequest = (HttpServletRequest) request;
            method = httpRequest.getMethod();
            path = httpRequest.getRequestURI().replace('/', '.').substring(1);
            sessionId = httpRequest.getSession().getId();
            query = httpRequest.getQueryString();
            if (query == null) {
                query = "";
            }
        } else {
            method = "POST";
            path = request.getServletContext().getContextPath().replace('/', '.').substring(1);
            sessionId = "<no session>";
            query = "";
        }
        componentSignature = path.replaceAll("\\.[A-Za-z0-9]*$", "");
        TraceMetadata trace = SessionAndTraceRegistrationFilter.TRACEREGISTRY.getTrace();
        final boolean newTrace = trace == null;
        if (newTrace) {
            SessionRegistry.INSTANCE.storeThreadLocalSessionId(sessionId);
            trace = SessionAndTraceRegistrationFilter.TRACEREGISTRY.registerTrace();
            SessionAndTraceRegistrationFilter.CTRLINST.newMonitoringRecord(trace);
        }
        if ("GET".equals(method)) {
            operationSignature = path + "(" + query.replace(';', ':') + ")";
        } else if ("POST".equals(method)) {
            operationSignature = path + "()";
        } else {
            chain.doFilter(request, response);
            return;
        }
        final long traceId = trace.getTraceId();
        try {
            SessionAndTraceRegistrationFilter.CTRLINST.newMonitoringRecord(new BeforeOperationEvent(SessionAndTraceRegistrationFilter.TIMESOURCE.getTime(), traceId, trace.getNextOrderId(), operationSignature, componentSignature));
            chain.doFilter(request, response);
            SessionAndTraceRegistrationFilter.CTRLINST.newMonitoringRecord(new AfterOperationEvent(SessionAndTraceRegistrationFilter.TIMESOURCE.getTime(), traceId, trace.getNextOrderId(), operationSignature, componentSignature));
        } catch (final Throwable th) {
            // NOPMD NOCS (catch throw is ok here)
            SessionAndTraceRegistrationFilter.CTRLINST.newMonitoringRecord(new AfterOperationFailedEvent(SessionAndTraceRegistrationFilter.TIMESOURCE.getTime(), traceId, trace.getNextOrderId(), operationSignature, componentSignature, th.toString()));
            throw new ServletException(th);
        } finally {
            // is this correct?
            SessionAndTraceRegistrationFilter.SESSION_REGISTRY.unsetThreadLocalSessionId();
            // Reset the thread-local trace information
            if (newTrace) {
                // close the trace
                SessionAndTraceRegistrationFilter.TRACEREGISTRY.unregisterTrace();
            }
        }
    // } else {
    // chain.doFilter(request, response);
    // return;
    // }
    } else {
        chain.doFilter(request, response);
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ServletException(javax.servlet.ServletException) AfterOperationFailedEvent(kieker.common.record.flow.trace.operation.AfterOperationFailedEvent) AfterOperationEvent(kieker.common.record.flow.trace.operation.AfterOperationEvent) TraceMetadata(kieker.common.record.flow.trace.TraceMetadata) BeforeOperationEvent(kieker.common.record.flow.trace.operation.BeforeOperationEvent)

Example 7 with AfterOperationEvent

use of kieker.common.record.flow.trace.operation.AfterOperationEvent in project iobserve-analysis by research-iobserve.

the class TranslateCallOperationEventsStage method sendWaiting.

private void sendWaiting(final long timestamp) {
    for (int i = 0; i < this.waitingList.size(); i++) {
        final AfterOperationEvent afterEvent = this.waitingList.get(i);
        if (timestamp > afterEvent.getTimestamp()) {
            this.outputPort.send(afterEvent);
            this.waitingList.remove(afterEvent);
            // NOCS necessary, as we delete elements from a list
            i--;
        }
    }
}
Also used : AfterOperationEvent(kieker.common.record.flow.trace.operation.AfterOperationEvent)

Example 8 with AfterOperationEvent

use of kieker.common.record.flow.trace.operation.AfterOperationEvent in project iobserve-analysis by research-iobserve.

the class AbstractOperationExecutionWithParameterAspect method operation.

@Around("monitoredOperation() && this(thisObject) && notWithinKieker()")
public Object operation(final Object thisObject, final ProceedingJoinPoint thisJoinPoint) throws Throwable {
    // (Throwable)
    if (!AbstractOperationExecutionWithParameterAspect.CTRLINST.isMonitoringEnabled()) {
        return thisJoinPoint.proceed();
    }
    final String operationSignature = this.signatureToLongString(thisJoinPoint.getSignature());
    if (!AbstractOperationExecutionWithParameterAspect.CTRLINST.isProbeActivated(operationSignature)) {
        return thisJoinPoint.proceed();
    }
    // common fields
    TraceMetadata trace = AbstractOperationExecutionWithParameterAspect.TRACEREGISTRY.getTrace();
    final boolean newTrace = trace == null;
    if (newTrace) {
        trace = AbstractOperationExecutionWithParameterAspect.TRACEREGISTRY.registerTrace();
        AbstractOperationExecutionWithParameterAspect.CTRLINST.newMonitoringRecord(trace);
    }
    final long traceId = trace.getTraceId();
    final String clazz = thisObject.getClass().getName();
    /**
     * extension over the original routine.
     */
    final String[] names = ((MethodSignature) thisJoinPoint.getSignature()).getParameterNames();
    final Object[] arguments = thisJoinPoint.getArgs();
    final String[] values = new String[arguments.length];
    int i = 0;
    for (final Object argument : arguments) {
        values[i++] = argument.toString();
    }
    /**
     * exchanged return type.
     */
    // measure before execution
    AbstractOperationExecutionWithParameterAspect.CTRLINST.newMonitoringRecord(new EntryLevelBeforeOperationEvent(AbstractOperationExecutionWithParameterAspect.TIME.getTime(), traceId, trace.getNextOrderId(), operationSignature, clazz, names, values, 0));
    // execution of the called method
    final Object retval;
    try {
        retval = thisJoinPoint.proceed();
    } catch (final Throwable th) {
        // NOPMD NOCS (catch throw might ok here)
        // measure after failed execution
        AbstractOperationExecutionWithParameterAspect.CTRLINST.newMonitoringRecord(new AfterOperationFailedEvent(AbstractOperationExecutionWithParameterAspect.TIME.getTime(), traceId, trace.getNextOrderId(), operationSignature, clazz, th.toString()));
        throw th;
    } finally {
        if (newTrace) {
            // close the trace
            AbstractOperationExecutionWithParameterAspect.TRACEREGISTRY.unregisterTrace();
        }
    }
    // measure after successful execution
    AbstractOperationExecutionWithParameterAspect.CTRLINST.newMonitoringRecord(new AfterOperationEvent(AbstractOperationExecutionWithParameterAspect.TIME.getTime(), traceId, trace.getNextOrderId(), operationSignature, clazz));
    return retval;
}
Also used : AfterOperationEvent(kieker.common.record.flow.trace.operation.AfterOperationEvent) MethodSignature(org.aspectj.lang.reflect.MethodSignature) ProceedingJoinPoint(org.aspectj.lang.ProceedingJoinPoint) AfterOperationFailedEvent(kieker.common.record.flow.trace.operation.AfterOperationFailedEvent) EntryLevelBeforeOperationEvent(org.iobserve.common.record.EntryLevelBeforeOperationEvent) TraceMetadata(kieker.common.record.flow.trace.TraceMetadata) Around(org.aspectj.lang.annotation.Around)

Example 9 with AfterOperationEvent

use of kieker.common.record.flow.trace.operation.AfterOperationEvent in project iobserve-analysis by research-iobserve.

the class SessionAndTraceRegistrationPayloadFilter method logMonitoringAndHandleFilterChain.

private void logMonitoringAndHandleFilterChain(final FilterChain chain, final ServletRequest request, final ServletResponse response, final long traceId, final int orderIndex, final String operationSignature, final String componentSignature, final String[] parameters, final String[] parameterValues, final int type, final boolean newTrace) throws ServletException {
    try {
        SessionAndTraceRegistrationPayloadFilter.CTRLINST.newMonitoringRecord(new EntryLevelBeforeOperationEvent(SessionAndTraceRegistrationPayloadFilter.TIMESOURCE.getTime(), traceId, orderIndex, operationSignature, componentSignature, parameters, parameterValues, type));
        chain.doFilter(request, response);
        SessionAndTraceRegistrationPayloadFilter.CTRLINST.newMonitoringRecord(new AfterOperationEvent(SessionAndTraceRegistrationPayloadFilter.TIMESOURCE.getTime(), traceId, orderIndex, operationSignature, componentSignature));
    } catch (final Throwable th) {
        // NOPMD NOCS (catch throw is ok here)
        SessionAndTraceRegistrationPayloadFilter.CTRLINST.newMonitoringRecord(new AfterOperationFailedEvent(SessionAndTraceRegistrationPayloadFilter.TIMESOURCE.getTime(), traceId, orderIndex, operationSignature, componentSignature, th.toString()));
        throw new ServletException(th);
    } finally {
        // is this correct?
        SessionAndTraceRegistrationPayloadFilter.SESSION_REGISTRY.unsetThreadLocalSessionId();
        // Reset the thread-local trace information
        if (newTrace) {
            // close the trace
            SessionAndTraceRegistrationPayloadFilter.TRACEREGISTRY.unregisterTrace();
        }
    }
}
Also used : ServletException(javax.servlet.ServletException) AfterOperationFailedEvent(kieker.common.record.flow.trace.operation.AfterOperationFailedEvent) AfterOperationEvent(kieker.common.record.flow.trace.operation.AfterOperationEvent) EntryLevelBeforeOperationEvent(org.iobserve.common.record.EntryLevelBeforeOperationEvent)

Example 10 with AfterOperationEvent

use of kieker.common.record.flow.trace.operation.AfterOperationEvent in project iobserve-analysis by research-iobserve.

the class DynamicEventDispatcherTest method initializeRecordSwitch.

/**
 * Initialize the record switch test setup.
 */
@Before
public void initializeRecordSwitch() {
    this.kiekerMetadataRecords.add(new KiekerMetadataRecord(DynamicEventDispatcherTest.VERSION, DynamicEventDispatcherTest.CONTROLLER_NAME, DynamicEventDispatcherTest.HOSTNAME, DynamicEventDispatcherTest.EXPERIMENT_ID, DynamicEventDispatcherTest.DEBUG_MODE, DynamicEventDispatcherTest.TIME_OFFSET, DynamicEventDispatcherTest.TIME_UNIT, DynamicEventDispatcherTest.NUMBER_OF_RECORDS));
    /**
     * allocation.
     */
    this.allocationRecords.add(new ContainerAllocationEvent(0, DynamicEventDispatcherTest.URL));
    /**
     * declare deployment records.
     */
    this.deploymentRecords.add(new ServletDeployedEvent(this.time++, DynamicEventDispatcherTest.SERVICE, DynamicEventDispatcherTest.CONTEXT, DynamicEventDispatcherTest.DEPLOYMENT_ID));
    this.deploymentRecords.add(new EJBDeployedEvent(this.time++, DynamicEventDispatcherTest.SERVICE, DynamicEventDispatcherTest.CONTEXT, DynamicEventDispatcherTest.DEPLOYMENT_ID));
    /**
     * geolocation.
     */
    this.geolocationRecords.add(new ServerGeoLocation(this.time++, DynamicEventDispatcherTest.COUNTRY_CODE, DynamicEventDispatcherTest.HOSTNAME, DynamicEventDispatcherTest.ADDRESS));
    /**
     * session event (start).
     */
    final SessionStartEvent sessionStartEvent = new SessionStartEvent(this.time++, DynamicEventDispatcherTest.HOSTNAME, DynamicEventDispatcherTest.SESSION_ID);
    this.sessionEventRecords.add(sessionStartEvent);
    /**
     * start trace.
     */
    final TraceMetadata traceMetadata = new TraceMetadata(DynamicEventDispatcherTest.TRACE_ID, DynamicEventDispatcherTest.THREAD_ID, DynamicEventDispatcherTest.SESSION_ID, DynamicEventDispatcherTest.HOSTNAME, 0, -1);
    this.traceMetadataRecords.add(traceMetadata);
    this.flowRecords.add(traceMetadata);
    /**
     * flow record.
     */
    this.flowRecords.add(new BeforeOperationEvent(this.time++, DynamicEventDispatcherTest.TRACE_ID, DynamicEventDispatcherTest.ORDER_INDEX, DynamicEventDispatcherTest.OPERATION_SIGNATURE, DynamicEventDispatcherTest.CLASS_SIGNATURE));
    this.flowRecords.add(new AfterOperationEvent(this.time++, DynamicEventDispatcherTest.TRACE_ID, DynamicEventDispatcherTest.ORDER_INDEX + 1, DynamicEventDispatcherTest.OPERATION_SIGNATURE, DynamicEventDispatcherTest.CLASS_SIGNATURE));
    /**
     * session event (end).
     */
    final SessionEndEvent sessionEndEvent = new SessionEndEvent(this.time++, DynamicEventDispatcherTest.HOSTNAME, DynamicEventDispatcherTest.SESSION_ID);
    this.sessionEventRecords.add(sessionEndEvent);
    /**
     * declare undeployment records.
     */
    this.undeploymentRecords.add(new ServletUndeployedEvent(this.time++, DynamicEventDispatcherTest.SERVICE, DynamicEventDispatcherTest.CONTEXT, DynamicEventDispatcherTest.DEPLOYMENT_ID));
    this.undeploymentRecords.add(new EJBUndeployedEvent(this.time++, DynamicEventDispatcherTest.SERVICE, DynamicEventDispatcherTest.CONTEXT, DynamicEventDispatcherTest.DEPLOYMENT_ID));
    /**
     * allocation.
     */
    this.deallocationRecords.add(new ContainerDeallocationEvent(0, DynamicEventDispatcherTest.URL));
    /**
     * other records.
     */
    this.otherRecords.add(new GCRecord(this.time++, DynamicEventDispatcherTest.HOSTNAME, DynamicEventDispatcherTest.VM_NAME, DynamicEventDispatcherTest.GC_NAME, DynamicEventDispatcherTest.COLLECTION_COUNT, DynamicEventDispatcherTest.COLLECTION_TIME_MS));
    /**
     * declare all input record types.
     */
    this.inputRecords.addAll(this.kiekerMetadataRecords);
    this.inputRecords.addAll(this.allocationRecords);
    this.inputRecords.addAll(this.deploymentRecords);
    this.inputRecords.addAll(this.geolocationRecords);
    this.inputRecords.add(sessionStartEvent);
    this.inputRecords.addAll(this.flowRecords);
    this.inputRecords.add(sessionEndEvent);
    this.inputRecords.addAll(this.undeploymentRecords);
    this.inputRecords.addAll(this.deallocationRecords);
    this.inputRecords.addAll(this.otherRecords);
/**
 * matcher.
 */
}
Also used : AfterOperationEvent(kieker.common.record.flow.trace.operation.AfterOperationEvent) EJBDeployedEvent(org.iobserve.common.record.EJBDeployedEvent) KiekerMetadataRecord(kieker.common.record.misc.KiekerMetadataRecord) EJBUndeployedEvent(org.iobserve.common.record.EJBUndeployedEvent) ContainerDeallocationEvent(org.iobserve.common.record.ContainerDeallocationEvent) GCRecord(kieker.common.record.jvm.GCRecord) ServletUndeployedEvent(org.iobserve.common.record.ServletUndeployedEvent) SessionStartEvent(org.iobserve.common.record.SessionStartEvent) SessionEndEvent(org.iobserve.common.record.SessionEndEvent) ContainerAllocationEvent(org.iobserve.common.record.ContainerAllocationEvent) ServerGeoLocation(org.iobserve.common.record.ServerGeoLocation) TraceMetadata(kieker.common.record.flow.trace.TraceMetadata) ServletDeployedEvent(org.iobserve.common.record.ServletDeployedEvent) BeforeOperationEvent(kieker.common.record.flow.trace.operation.BeforeOperationEvent) Before(org.junit.Before)

Aggregations

AfterOperationEvent (kieker.common.record.flow.trace.operation.AfterOperationEvent)11 BeforeOperationEvent (kieker.common.record.flow.trace.operation.BeforeOperationEvent)8 TraceMetadata (kieker.common.record.flow.trace.TraceMetadata)6 AfterOperationFailedEvent (kieker.common.record.flow.trace.operation.AfterOperationFailedEvent)6 EntryLevelBeforeOperationEvent (org.iobserve.common.record.EntryLevelBeforeOperationEvent)4 ServletException (javax.servlet.ServletException)2 GCRecord (kieker.common.record.jvm.GCRecord)2 KiekerMetadataRecord (kieker.common.record.misc.KiekerMetadataRecord)2 Around (org.aspectj.lang.annotation.Around)2 MethodSignature (org.aspectj.lang.reflect.MethodSignature)2 ContainerAllocationEvent (org.iobserve.common.record.ContainerAllocationEvent)2 ContainerDeallocationEvent (org.iobserve.common.record.ContainerDeallocationEvent)2 EJBDeployedEvent (org.iobserve.common.record.EJBDeployedEvent)2 EJBUndeployedEvent (org.iobserve.common.record.EJBUndeployedEvent)2 ServerGeoLocation (org.iobserve.common.record.ServerGeoLocation)2 ServletDeployedEvent (org.iobserve.common.record.ServletDeployedEvent)2 ServletUndeployedEvent (org.iobserve.common.record.ServletUndeployedEvent)2 SessionEndEvent (org.iobserve.common.record.SessionEndEvent)2 SessionStartEvent (org.iobserve.common.record.SessionStartEvent)2 Before (org.junit.Before)2