Search in sources :

Example 1 with BasicStatisticDataUnit

use of org.apache.synapse.aspects.flow.statistics.data.raw.BasicStatisticDataUnit in project wso2-synapse by wso2.

the class JaegerSpanHandler method finishSpan.

/**
 * Ends a span which is related to the provided basic statistic data unit, and performs necessary updates or
 * removals in the provided span store.
 * @param basicStatisticDataUnit    Basic statistic data unit object, which was collected during a statistic event.
 * @param synCtx                    Message context.
 * @param spanStore                 Span store object.
 * @param tracingScope              The tracing scope of the appropriate span.
 */
private void finishSpan(BasicStatisticDataUnit basicStatisticDataUnit, MessageContext synCtx, SpanStore spanStore, TracingScope tracingScope) {
    String spanWrapperId = TracingUtils.extractId(basicStatisticDataUnit);
    SpanWrapper spanWrapper = spanStore.getSpanWrapper(spanWrapperId);
    // Set the statistic data unit of the close event into the span wrapper
    if (spanWrapper != null && (basicStatisticDataUnit instanceof StatisticDataUnit)) {
        spanWrapper.setCloseEventStatisticDataUnit((StatisticDataUnit) basicStatisticDataUnit);
    }
    if (!Objects.equals(spanWrapper, spanStore.getOuterLevelSpanWrapper())) {
        // A non-outer level span
        spanStore.finishSpan(spanWrapper);
    } else {
        // An outer level span
        if (tracingScope.isEventCollectionFinished(synCtx)) {
            cleanupContinuationStateSequences(spanStore);
            spanStore.finishSpan(spanWrapper);
            tracingScopeManager.cleanupTracingScope(tracingScope.getTracingScopeId());
        }
    // Else - Absorb. Will be handled when all the callbacks are completed
    }
}
Also used : BasicStatisticDataUnit(org.apache.synapse.aspects.flow.statistics.data.raw.BasicStatisticDataUnit) StatisticDataUnit(org.apache.synapse.aspects.flow.statistics.data.raw.StatisticDataUnit) SpanWrapper(org.apache.synapse.aspects.flow.statistics.opentracing.models.SpanWrapper)

Example 2 with BasicStatisticDataUnit

use of org.apache.synapse.aspects.flow.statistics.data.raw.BasicStatisticDataUnit in project wso2-synapse by wso2.

the class OpenEventCollector method openContinuationEvents.

/**
 * Add event in to the event queue. This event will inform statistic collection to put all the flow continuable
 * mediators before the index specified by current Index to open state.
 *
 * @param synCtx synapse message context.
 */
public static void openContinuationEvents(MessageContext synCtx) {
    if (shouldReportStatistic(synCtx)) {
        BasicStatisticDataUnit basicStatisticDataUnit = new BasicStatisticDataUnit();
        basicStatisticDataUnit.setCurrentIndex(StatisticDataCollectionHelper.getParentFlowPosition(synCtx, null));
        basicStatisticDataUnit.setStatisticId(StatisticDataCollectionHelper.getStatisticTraceId(synCtx));
        ParentReopenEvent parentReopenEvent = new ParentReopenEvent(basicStatisticDataUnit);
        addEvent(synCtx, parentReopenEvent);
        if (isOpenTracingEnabled()) {
            OpenTracingManagerHolder.getOpenTracingManager().getHandler().handleOpenContinuationEvents(basicStatisticDataUnit, synCtx);
        }
    }
}
Also used : ParentReopenEvent(org.apache.synapse.aspects.flow.statistics.log.templates.ParentReopenEvent) BasicStatisticDataUnit(org.apache.synapse.aspects.flow.statistics.data.raw.BasicStatisticDataUnit)

Example 3 with BasicStatisticDataUnit

use of org.apache.synapse.aspects.flow.statistics.data.raw.BasicStatisticDataUnit in project wso2-synapse by wso2.

the class OpenEventCollector method reportFlowAsynchronousEvent.

/**
 * Enqueue StatisticOpenEvent for asynchronous invocation.
 *
 * @param messageContext synapse message context.
 */
public static void reportFlowAsynchronousEvent(MessageContext messageContext) {
    if (shouldReportStatistic(messageContext)) {
        BasicStatisticDataUnit dataUnit = new BasicStatisticDataUnit();
        dataUnit.setStatisticId(StatisticDataCollectionHelper.getStatisticTraceId(messageContext));
        dataUnit.setCurrentIndex(StatisticDataCollectionHelper.getParentFlowPosition(messageContext, null));
        AsynchronousExecutionEvent asynchronousExecutionEvent = new AsynchronousExecutionEvent(dataUnit);
        if (isOpenTracingEnabled()) {
            OpenTracingManagerHolder.getOpenTracingManager().getHandler().handleOpenFlowAsynchronousEvent(dataUnit, messageContext);
        }
        addEventAndIncrementCount(messageContext, asynchronousExecutionEvent);
    }
}
Also used : AsynchronousExecutionEvent(org.apache.synapse.aspects.flow.statistics.log.templates.AsynchronousExecutionEvent) BasicStatisticDataUnit(org.apache.synapse.aspects.flow.statistics.data.raw.BasicStatisticDataUnit)

Example 4 with BasicStatisticDataUnit

use of org.apache.synapse.aspects.flow.statistics.data.raw.BasicStatisticDataUnit in project wso2-synapse by wso2.

the class CloseEventCollector method closeFlowForcefully.

/**
 * Enqueue statistics event to the event queue. This method invokes when fault sequence finished handling the fault
 * occurred in the message flow.
 *
 * @param messageContext synapse message context.
 */
public static void closeFlowForcefully(MessageContext messageContext, boolean error) {
    if (shouldReportStatistic(messageContext)) {
        BasicStatisticDataUnit dataUnit = new BasicStatisticDataUnit();
        dataUnit.setTime(System.currentTimeMillis());
        dataUnit.setSynapseEnvironment(messageContext.getEnvironment());
        dataUnit.setStatisticId(StatisticDataCollectionHelper.getStatisticTraceId(messageContext));
        dataUnit.setCurrentIndex(StatisticDataCollectionHelper.getParentFlowPosition(messageContext, null));
        EndFlowEvent endFlowEvent = new EndFlowEvent(dataUnit);
        if (!error) {
            addEventAndDecrementCount(messageContext, endFlowEvent);
        } else {
            addEventAndCloseFlow(messageContext, endFlowEvent);
        }
        if (isOpenTracingEnabled()) {
            OpenTracingManagerHolder.getOpenTracingManager().getHandler().handleCloseFlowForcefully(dataUnit, messageContext);
        }
    }
}
Also used : EndFlowEvent(org.apache.synapse.aspects.flow.statistics.log.templates.EndFlowEvent) BasicStatisticDataUnit(org.apache.synapse.aspects.flow.statistics.data.raw.BasicStatisticDataUnit)

Example 5 with BasicStatisticDataUnit

use of org.apache.synapse.aspects.flow.statistics.data.raw.BasicStatisticDataUnit in project wso2-synapse by wso2.

the class FaultStatisticCollector method reportFault.

/**
 * Enqueue Fault Event to the event queue indicating that fault has occurred in the message flow.
 *
 * @param messageContext messageContext of the message flow.
 */
public static void reportFault(MessageContext messageContext) {
    if (shouldReportStatistic(messageContext)) {
        boolean isFaultCreated = isFaultAlreadyReported(messageContext);
        if (!isFaultCreated) {
            BasicStatisticDataUnit dataUnit = new BasicStatisticDataUnit();
            dataUnit.setStatisticId(StatisticDataCollectionHelper.getStatisticTraceId(messageContext));
            dataUnit.setCurrentIndex(StatisticDataCollectionHelper.getParentFlowPosition(messageContext, null));
            FaultEvent faultEvent = new FaultEvent(dataUnit);
            addEventAndIncrementCount(messageContext, faultEvent);
        }
    }
}
Also used : FaultEvent(org.apache.synapse.aspects.flow.statistics.log.templates.FaultEvent) BasicStatisticDataUnit(org.apache.synapse.aspects.flow.statistics.data.raw.BasicStatisticDataUnit)

Aggregations

BasicStatisticDataUnit (org.apache.synapse.aspects.flow.statistics.data.raw.BasicStatisticDataUnit)5 StatisticDataUnit (org.apache.synapse.aspects.flow.statistics.data.raw.StatisticDataUnit)1 AsynchronousExecutionEvent (org.apache.synapse.aspects.flow.statistics.log.templates.AsynchronousExecutionEvent)1 EndFlowEvent (org.apache.synapse.aspects.flow.statistics.log.templates.EndFlowEvent)1 FaultEvent (org.apache.synapse.aspects.flow.statistics.log.templates.FaultEvent)1 ParentReopenEvent (org.apache.synapse.aspects.flow.statistics.log.templates.ParentReopenEvent)1 SpanWrapper (org.apache.synapse.aspects.flow.statistics.opentracing.models.SpanWrapper)1