Search in sources :

Example 11 with AnalyticsException

use of org.wso2.carbon.apimgt.common.analytics.exceptions.AnalyticsException in project carbon-apimgt by wso2.

the class MethodNotAllowedFaultDataCollector method collectFaultData.

@Override
public void collectFaultData(Event faultyEvent) throws AnalyticsException {
    log.debug("handling method not allowed failure analytics events");
    Application application = getUnknownApp();
    faultyEvent.setApplication(application);
    this.processRequest(faultyEvent);
}
Also used : Application(org.wso2.carbon.apimgt.common.analytics.publishers.dto.Application)

Example 12 with AnalyticsException

use of org.wso2.carbon.apimgt.common.analytics.exceptions.AnalyticsException in project carbon-apimgt by wso2.

the class TargetFaultDataCollector method collectFaultData.

@Override
public void collectFaultData(Event faultyEvent) throws AnalyticsException {
    log.debug("handling target failure analytics events");
    Application application;
    if (provider.isAuthenticated() && provider.isAnonymous()) {
        application = getAnonymousApp();
    } else {
        application = provider.getApplication();
    }
    faultyEvent.setApplication(application);
    this.processRequest(faultyEvent);
}
Also used : Application(org.wso2.carbon.apimgt.common.analytics.publishers.dto.Application)

Example 13 with AnalyticsException

use of org.wso2.carbon.apimgt.common.analytics.exceptions.AnalyticsException in project carbon-apimgt by wso2.

the class UnclassifiedFaultDataCollector method collectFaultData.

@Override
public void collectFaultData(Event faultyEvent) throws AnalyticsException {
    log.debug("handling unclassified failure analytics events");
    Application application;
    if (provider.isAuthenticated()) {
        if (provider.isAnonymous()) {
            application = getAnonymousApp();
        } else {
            application = provider.getApplication();
        }
    } else {
        application = getUnknownApp();
    }
    faultyEvent.setApplication(application);
    this.processRequest(faultyEvent);
}
Also used : Application(org.wso2.carbon.apimgt.common.analytics.publishers.dto.Application)

Example 14 with AnalyticsException

use of org.wso2.carbon.apimgt.common.analytics.exceptions.AnalyticsException in project carbon-apimgt by wso2.

the class SseResponseStreamInterceptor method handleThrottlingAndAnalytics.

private boolean handleThrottlingAndAnalytics(int eventCount, MessageContext axi2Ctx) {
    Object throttleObject = axi2Ctx.getProperty(SSE_THROTTLE_DTO);
    if (throttleObject != null) {
        String messageId = UIDGenerator.generateURNString();
        ThrottleInfo throttleInfo = (ThrottleInfo) throttleObject;
        String remoteIP = throttleInfo.getRemoteIp();
        JSONObject propertiesMap = new JSONObject();
        Utils.setRemoteIp(propertiesMap, remoteIP);
        boolean isThrottled = isThrottled(throttleInfo.getSubscriberTenantDomain(), throttleInfo.getResourceLevelThrottleKey(), throttleInfo.getSubscriptionLevelThrottleKey(), throttleInfo.getApplicationLevelThrottleKey());
        if (isThrottled) {
            log.warn("Request is throttled out");
            return false;
        }
        throttlePublisherService.execute(() -> SseUtils.publishNonThrottledEvent(eventCount, messageId, throttleInfo, propertiesMap));
        if (APIUtil.isAnalyticsEnabled()) {
            try {
                publishAnalyticsData(eventCount, axi2Ctx);
            } catch (AnalyticsException e) {
                log.error("Error while publishing analytics data", e);
            }
        }
        return true;
    } else {
        log.error("Throttle object cannot be null.");
    }
    return true;
}
Also used : ThrottleInfo(org.wso2.carbon.apimgt.gateway.handlers.streaming.sse.throttling.ThrottleInfo) JSONObject(org.json.JSONObject) AnalyticsException(org.wso2.carbon.apimgt.common.analytics.exceptions.AnalyticsException) JSONObject(org.json.JSONObject)

Example 15 with AnalyticsException

use of org.wso2.carbon.apimgt.common.analytics.exceptions.AnalyticsException in project carbon-apimgt by wso2.

the class FaultyRequestDataCollector method collectData.

public void collectData() throws AnalyticsException {
    log.debug("Handling faulty analytics types");
    Event faultyEvent = getFaultyEvent();
    switch(provider.getFaultType()) {
        case AUTH:
            authDataCollector.collectFaultData(faultyEvent);
            break;
        case THROTTLED:
            throttledDataCollector.collectFaultData(faultyEvent);
            break;
        case TARGET_CONNECTIVITY:
            targetDataCollector.collectFaultData(faultyEvent);
            break;
        case OTHER:
            unclassifiedFaultDataCollector.collectFaultData(faultyEvent);
            break;
    }
}
Also used : Event(org.wso2.carbon.apimgt.common.analytics.publishers.dto.Event)

Aggregations

Application (org.wso2.carbon.apimgt.common.analytics.publishers.dto.Application)7 GenericRequestDataCollector (org.wso2.carbon.apimgt.common.analytics.collectors.impl.GenericRequestDataCollector)3 AnalyticsException (org.wso2.carbon.apimgt.common.analytics.exceptions.AnalyticsException)3 ArrayList (java.util.ArrayList)2 Consumes (javax.ws.rs.Consumes)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 JSONObject (org.json.JSONObject)2 AnalyticsDataAPI (org.wso2.carbon.analytics.api.AnalyticsDataAPI)2 AnalyticsDataResponse (org.wso2.carbon.analytics.dataservice.commons.AnalyticsDataResponse)2 SearchResultEntry (org.wso2.carbon.analytics.dataservice.commons.SearchResultEntry)2 SortByField (org.wso2.carbon.analytics.dataservice.commons.SortByField)2 AnalyticsException (org.wso2.carbon.analytics.datasource.commons.exception.AnalyticsException)2 Event (org.wso2.carbon.apimgt.common.analytics.publishers.dto.Event)2 DeviceIdentifier (org.wso2.carbon.device.mgt.common.DeviceIdentifier)2 DeviceAccessAuthorizationException (org.wso2.carbon.device.mgt.common.authorization.DeviceAccessAuthorizationException)2 SensorRecord (org.wso2.iot.sampledevice.api.dto.SensorRecord)2 Axis2MessageContext (org.apache.synapse.core.axis2.Axis2MessageContext)1 SensorRecord (org.coffeeking.api.util.SensorRecord)1