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