use of org.wso2.carbon.apimgt.common.analytics.collectors.AnalyticsDataProvider in project carbon-apimgt by wso2.
the class SseApiHandler method isThrottled.
private boolean isThrottled(org.apache.axis2.context.MessageContext axisCtx, MessageContext synCtx) {
AuthenticationContext authenticationContext = APISecurityUtils.getAuthenticationContext(synCtx);
ThrottleInfo throttleInfo = getThrottlingInfo(authenticationContext, synCtx);
boolean isThrottled = SseUtils.isRequestBlocked(authenticationContext, throttleInfo.getApiContext(), throttleInfo.getApiVersion(), authenticationContext.getUsername(), throttleInfo.getRemoteIp(), CarbonContext.getThreadLocalCarbonContext().getTenantDomain());
if (!isThrottled) {
// do throttling if request is not blocked by global conditions only
isThrottled = SseUtils.isThrottled(throttleInfo.getSubscriberTenantDomain(), throttleInfo.getResourceLevelThrottleKey(), throttleInfo.getSubscriptionLevelThrottleKey(), throttleInfo.getApplicationLevelThrottleKey());
}
if (isThrottled) {
handleThrottledOut(synCtx);
return true;
}
if (APIUtil.isAnalyticsEnabled()) {
AnalyticsDataProvider provider = new SseResponseEventDataProvider(synCtx);
axisCtx.setProperty(SSE_ANALYTICS_INFO, provider);
}
return false;
}
use of org.wso2.carbon.apimgt.common.analytics.collectors.AnalyticsDataProvider 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.AnalyticsDataProvider 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