use of org.wso2.carbon.apimgt.common.analytics.collectors.impl.GenericRequestDataCollector in project carbon-apimgt by wso2.
the class WebhooksUtils method publishAnalyticsData.
public static void publishAnalyticsData(MessageContext messageContext) {
org.apache.axis2.context.MessageContext axisCtx = ((Axis2MessageContext) messageContext).getAxis2MessageContext();
axisCtx.setProperty(PassThroughConstants.SYNAPSE_ARTIFACT_TYPE, APIConstants.API_TYPE_WEBSUB);
WebhooksAnalyticsDataProvider provider = new WebhooksAnalyticsDataProvider(messageContext);
GenericRequestDataCollector dataCollector = new GenericRequestDataCollector(provider);
try {
dataCollector.collectData();
} catch (AnalyticsException e) {
log.error("Error occurred when collecting data", e);
}
}
use of org.wso2.carbon.apimgt.common.analytics.collectors.impl.GenericRequestDataCollector in project carbon-apimgt by wso2.
the class SseResponseStreamInterceptor method publishAnalyticsData.
private void publishAnalyticsData(int eventCount, MessageContext axi2Ctx) throws AnalyticsException {
Object responseEventProvider = axi2Ctx.getProperty(SSE_ANALYTICS_INFO);
if (responseEventProvider == null) {
log.error("SSE Analytics event provider is null.");
return;
}
SseResponseEventDataProvider provider = (SseResponseEventDataProvider) responseEventProvider;
provider.setResponseCode((int) axi2Ctx.getProperty(SynapseConstants.HTTP_SC));
GenericRequestDataCollector dataCollector = new GenericRequestDataCollector(provider);
for (int count = 0; count < eventCount; count++) {
dataCollector.collectData();
}
}
use of org.wso2.carbon.apimgt.common.analytics.collectors.impl.GenericRequestDataCollector in project carbon-apimgt by wso2.
the class WebSocketAnalyticsMetricsHandler method collectData.
private void collectData(ChannelHandlerContext ctx) {
AnalyticsDataProvider provider = new WebSocketAnalyticsDataProvider(ctx);
GenericRequestDataCollector collector = new GenericRequestDataCollector(provider);
try {
collector.collectData();
} catch (AnalyticsException e) {
log.error("Error Occurred when collecting analytics data", e);
}
}
use of org.wso2.carbon.apimgt.common.analytics.collectors.impl.GenericRequestDataCollector in project carbon-apimgt by wso2.
the class SubscriberInfoLoader method mediate.
// private final GenericRequestDataCollector dataCollector = null;
@Override
public boolean mediate(MessageContext messageContext) {
List<WebhooksDTO> subscribersList = (List<WebhooksDTO>) messageContext.getProperty(APIConstants.Webhooks.SUBSCRIBERS_LIST_PROPERTY);
int index = (Integer) messageContext.getProperty(APIConstants.CLONED_ITERATION_INDEX_PROPERTY);
WebhooksDTO subscriber = subscribersList.get(index - 1);
if (subscriber != null) {
boolean canProceed = handleThrottle(subscriber, messageContext);
if (!canProceed) {
return false;
}
messageContext.setProperty(APIConstants.Webhooks.SUBSCRIBER_CALLBACK_PROPERTY, subscriber.getCallbackURL());
messageContext.setProperty(APIConstants.Webhooks.SUBSCRIBER_SECRET_PROPERTY, subscriber.getSecret());
messageContext.setProperty(APIConstants.Webhooks.SUBSCRIBER_APPLICATION_ID_PROPERTY, subscriber.getAppID());
}
return true;
}
use of org.wso2.carbon.apimgt.common.analytics.collectors.impl.GenericRequestDataCollector in project carbon-apimgt by wso2.
the class AnalyticsMetricsHandler method handleResponseOutFlow.
@Override
public boolean handleResponseOutFlow(MessageContext messageContext) {
if (messageContext.getPropertyKeySet().contains(InboundWebsocketConstants.WEBSOCKET_SUBSCRIBER_PATH)) {
return true;
}
AnalyticsDataProvider provider;
Object skipPublishMetrics = messageContext.getProperty(Constants.SKIP_DEFAULT_METRICS_PUBLISHING);
if (skipPublishMetrics != null && (Boolean) skipPublishMetrics) {
provider = new AsyncAnalyticsDataProvider(messageContext);
} else {
provider = new SynapseAnalyticsDataProvider(messageContext);
}
GenericRequestDataCollector dataCollector = new GenericRequestDataCollector(provider);
try {
dataCollector.collectData();
} catch (Exception e) {
log.error("Error Occurred when collecting data", e);
}
return true;
}
Aggregations