Search in sources :

Example 1 with StatisticDataUnit

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

the class OpenEventCollector method reportChildEntryEvent.

/**
 * Enqueue StatisticOpenEvent to the event Queue. This receives open events from Mediators and Resources. These
 * components can't start statistic collection. If statistics is already enabled, it will enqueue open event to
 * the queue regardless of its individual statistics collection. If its disabled it will not enqueue open event
 * to the event queue.
 *
 * @param messageContext      synapse message context.
 * @param componentName       statistic reporting component name.
 * @param componentType       component type of the reporting component.
 * @param aspectConfiguration aspect configuration of the component
 * @param isContentAltering   component is altering the content
 * @return component's level in this message flow.
 */
public static Integer reportChildEntryEvent(MessageContext messageContext, String componentName, ComponentType componentType, AspectConfiguration aspectConfiguration, boolean isContentAltering) {
    if (shouldReportStatistic(messageContext)) {
        StatisticDataUnit statisticDataUnit = new StatisticDataUnit();
        reportMediatorStatistics(messageContext, componentName, componentType, isContentAltering, statisticDataUnit, aspectConfiguration);
        if (isOpenTracingEnabled()) {
            OpenTracingManagerHolder.getOpenTracingManager().getHandler().handleOpenChildEntryEvent(statisticDataUnit, messageContext);
        }
        return statisticDataUnit.getCurrentIndex();
    }
    return null;
}
Also used : BasicStatisticDataUnit(org.apache.synapse.aspects.flow.statistics.data.raw.BasicStatisticDataUnit) StatisticDataUnit(org.apache.synapse.aspects.flow.statistics.data.raw.StatisticDataUnit)

Example 2 with StatisticDataUnit

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

the class OpenEventCollector method reportFlowContinuableEvent.

/**
 * Enqueue StatisticOpenEvent to the event Queue. This receives open events from Flow Continuable Mediators. These
 * components can't start statistic collection. If statistics is already enabled, it will enqueue open event to
 * the queue regardless of its individual statistics collection. If its disabled it will not enqueue open event
 * to the event queue.
 *
 * @param messageContext      synapse message context.
 * @param componentName       statistic reporting component name.
 * @param componentType       component type of the reporting component.
 * @param aspectConfiguration aspect configuration of the component
 * @param isContentAltering   component is altering the content
 * @return component's level in this message flow.
 */
public static Integer reportFlowContinuableEvent(MessageContext messageContext, String componentName, ComponentType componentType, AspectConfiguration aspectConfiguration, boolean isContentAltering) {
    if (shouldReportStatistic(messageContext)) {
        StatisticDataUnit statisticDataUnit = new StatisticDataUnit();
        statisticDataUnit.setFlowContinuableMediator(true);
        reportMediatorStatistics(messageContext, componentName, componentType, isContentAltering, statisticDataUnit, aspectConfiguration);
        if (isOpenTracingEnabled()) {
            OpenTracingManagerHolder.getOpenTracingManager().getHandler().handleOpenFlowContinuableEvent(statisticDataUnit, messageContext);
        }
        return statisticDataUnit.getCurrentIndex();
    }
    return null;
}
Also used : BasicStatisticDataUnit(org.apache.synapse.aspects.flow.statistics.data.raw.BasicStatisticDataUnit) StatisticDataUnit(org.apache.synapse.aspects.flow.statistics.data.raw.StatisticDataUnit)

Example 3 with StatisticDataUnit

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

the class OpenEventCollector method reportFlowSplittingEvent.

/**
 * Enqueue StatisticOpenEvent to the event Queue. This receives open events from Flow Splitting Mediators like
 * Clone Mediator and Iterate Mediator. These components can't start statistic collection. If statistics is
 * already enabled, it will enqueue open event to the queue regardless of its individual statistics collection.
 * If its disabled it will not enqueue open event to the event queue.
 *
 * @param messageContext      synapse message context.
 * @param componentName       statistic reporting component name.
 * @param componentType       component type of the reporting component.
 * @param aspectConfiguration aspect configuration of the component
 * @param isContentAltering   component is altering the content
 * @return component's level in this message flow.
 */
public static Integer reportFlowSplittingEvent(MessageContext messageContext, String componentName, ComponentType componentType, AspectConfiguration aspectConfiguration, boolean isContentAltering) {
    if (shouldReportStatistic(messageContext)) {
        StatisticDataUnit statisticDataUnit = new StatisticDataUnit();
        statisticDataUnit.setFlowContinuableMediator(true);
        statisticDataUnit.setFlowSplittingMediator(true);
        reportMediatorStatistics(messageContext, componentName, componentType, isContentAltering, statisticDataUnit, aspectConfiguration);
        if (isOpenTracingEnabled()) {
            OpenTracingManagerHolder.getOpenTracingManager().getHandler().handleOpenFlowSplittingEvent(statisticDataUnit, messageContext);
        }
        return statisticDataUnit.getCurrentIndex();
    }
    return null;
}
Also used : BasicStatisticDataUnit(org.apache.synapse.aspects.flow.statistics.data.raw.BasicStatisticDataUnit) StatisticDataUnit(org.apache.synapse.aspects.flow.statistics.data.raw.StatisticDataUnit)

Example 4 with StatisticDataUnit

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

the class OpenEventCollector method reportEntryEvent.

/**
 * Enqueue StatisticOpenEvent to the event Queue. This receives open events from Proxy Services, Endpoints, APIs,
 * Inbound Endpoints and Sequences which are considered as entry components for statistics collection. These
 * components can start statistic collection if their individual statistic collection is enabled. If statistics
 * is already enabled, this will enqueue open event to the queue regardless of its individual statistics collection.
 *
 * @param messageContext      synapse message context.
 * @param componentName       statistic reporting component name.
 * @param aspectConfiguration aspect configuration of the reporting component.
 * @param componentType       component type of the reporting component.
 * @return component's level in this message flow.
 */
public static Integer reportEntryEvent(MessageContext messageContext, String componentName, AspectConfiguration aspectConfiguration, ComponentType componentType) {
    boolean isCollectingStatistics = (aspectConfiguration != null && aspectConfiguration.isStatisticsEnable());
    // Enable statistics, if user enabled for all artifacts
    if (!isCollectingStatistics) {
        isCollectingStatistics = isCollectingStatistics || RuntimeStatisticCollector.isCollectingAllStatistics();
    }
    boolean isCollectingTracing = false;
    if (isCollectingProperties() || isCollectingPayloads()) {
        isCollectingTracing = (aspectConfiguration != null && aspectConfiguration.isTracingEnabled());
    }
    Boolean isFlowStatisticEnabled = // todo try to use single object for "FLOW_TRACE_IS_COLLECTED"
    (Boolean) messageContext.getProperty(StatisticsConstants.FLOW_STATISTICS_IS_COLLECTED);
    Boolean isTracingEnabled;
    if (isCollectingStatistics) {
        messageContext.setProperty(StatisticsConstants.FLOW_STATISTICS_IS_COLLECTED, true);
        setStatisticsTraceId(messageContext);
        if (isCollectingTracing) {
            messageContext.setProperty(StatisticsConstants.FLOW_TRACE_IS_COLLECTED, true);
        }
    } else if (isFlowStatisticEnabled == null) {
        // To signal lower levels that statistics was disabled in upper component in the flow
        messageContext.setProperty(StatisticsConstants.FLOW_STATISTICS_IS_COLLECTED, false);
    }
    isTracingEnabled = (Boolean) messageContext.getProperty(StatisticsConstants.FLOW_TRACE_IS_COLLECTED);
    if (shouldReportStatistic(messageContext)) {
        StatisticDataUnit statisticDataUnit = new StatisticDataUnit();
        statisticDataUnit.setComponentName(componentName);
        statisticDataUnit.setComponentType(componentType);
        statisticDataUnit.setTracingEnabled(isCollectingTracing);
        statisticDataUnit.setSynapseEnvironment(messageContext.getEnvironment());
        statisticDataUnit.setCurrentIndex(StatisticDataCollectionHelper.getFlowPosition(messageContext));
        if (aspectConfiguration != null) {
            statisticDataUnit.setComponentId(aspectConfiguration.getUniqueId());
            statisticDataUnit.setHashCode(aspectConfiguration.getHashCode());
        }
        int parentIndex = StatisticDataCollectionHelper.getParentFlowPosition(messageContext, statisticDataUnit.getCurrentIndex());
        statisticDataUnit.setParentIndex(parentIndex);
        if (statisticDataUnit.getComponentType() != ComponentType.ENDPOINT) {
            statisticDataUnit.setFlowContinuableMediator(true);
        }
        if (aspectConfiguration != null) {
            statisticDataUnit.setIsIndividualStatisticCollected(isCollectingStatistics);
        }
        StatisticDataCollectionHelper.collectData(messageContext, true, isTracingEnabled, statisticDataUnit);
        StatisticsOpenEvent openEvent = new StatisticsOpenEvent(statisticDataUnit);
        addEventAndIncrementCount(messageContext, openEvent);
        if (isOpenTracingEnabled()) {
            OpenTracingManagerHolder.getOpenTracingManager().getHandler().handleOpenEntryEvent(statisticDataUnit, messageContext);
        }
        return statisticDataUnit.getCurrentIndex();
    }
    return null;
}
Also used : BasicStatisticDataUnit(org.apache.synapse.aspects.flow.statistics.data.raw.BasicStatisticDataUnit) StatisticDataUnit(org.apache.synapse.aspects.flow.statistics.data.raw.StatisticDataUnit) StatisticsOpenEvent(org.apache.synapse.aspects.flow.statistics.log.templates.StatisticsOpenEvent)

Example 5 with StatisticDataUnit

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

the class OpenEventCollector method reportFlowAggregateEvent.

/**
 * Enqueue StatisticOpenEvent to the event Queue. This receives open events from Flow Aggregate Mediator. These
 * components can't start statistic collection. If statistics is already enabled, it will enqueue open event to
 * the queue regardless of its individual statistics collection. If its disabled it will not enqueue open event
 * to the event queue.
 *
 * @param messageContext      synapse message context.
 * @param componentName       statistic reporting component name.
 * @param componentType       component type of the component.
 * @param aspectConfiguration aspect configuration of the component
 * @param isContentAltering   component is altering the content
 * @return component's level in this message flow.
 */
public static Integer reportFlowAggregateEvent(MessageContext messageContext, String componentName, ComponentType componentType, AspectConfiguration aspectConfiguration, boolean isContentAltering) {
    if (shouldReportStatistic(messageContext)) {
        StatisticDataUnit statisticDataUnit = new StatisticDataUnit();
        statisticDataUnit.setFlowContinuableMediator(true);
        statisticDataUnit.setFlowAggregateMediator(true);
        reportMediatorStatistics(messageContext, componentName, componentType, isContentAltering, statisticDataUnit, aspectConfiguration);
        if (isOpenTracingEnabled()) {
            OpenTracingManagerHolder.getOpenTracingManager().getHandler().handleOpenFlowAggregateEvent(statisticDataUnit, messageContext);
        }
        return statisticDataUnit.getCurrentIndex();
    }
    return null;
}
Also used : BasicStatisticDataUnit(org.apache.synapse.aspects.flow.statistics.data.raw.BasicStatisticDataUnit) StatisticDataUnit(org.apache.synapse.aspects.flow.statistics.data.raw.StatisticDataUnit)

Aggregations

StatisticDataUnit (org.apache.synapse.aspects.flow.statistics.data.raw.StatisticDataUnit)12 BasicStatisticDataUnit (org.apache.synapse.aspects.flow.statistics.data.raw.BasicStatisticDataUnit)8 StatisticsLog (org.apache.synapse.aspects.flow.statistics.data.raw.StatisticsLog)2 SpanWrapper (org.apache.synapse.aspects.flow.statistics.opentracing.models.SpanWrapper)2 Span (io.opentracing.Span)1 StatisticsCloseEvent (org.apache.synapse.aspects.flow.statistics.log.templates.StatisticsCloseEvent)1 StatisticsOpenEvent (org.apache.synapse.aspects.flow.statistics.log.templates.StatisticsOpenEvent)1 TracingScope (org.apache.synapse.aspects.flow.statistics.opentracing.management.scoping.TracingScope)1 ContinuationStateSequenceInfo (org.apache.synapse.aspects.flow.statistics.opentracing.models.ContinuationStateSequenceInfo)1 BeforeClass (org.junit.BeforeClass)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1